Docker is a platform for developing, shipping, and running applications using containerization technology. It allows developers to package their applications and their dependencies into lightweight, portable containers that can be run on any machine that supports Docker. With Docker, developers can easily deploy their applications in different environments without worrying about compatibility issues or dependencies conflicts. Docker also enables teams to work together more efficiently by providing a consistent and reproducible environment for their applications.

Docker Compose is a tool for defining and running multi-container Docker applications. It allows developers to define their applications using a YAML file and start all the containers that make up the application with a single command. With Docker Compose, developers can easily configure their applications and their dependencies, orchestrate the start-up order of their containers, and manage the communication between them. Docker Compose also provides a simple way to scale and manage the containers of an application, making it a useful tool for building and deploying complex microservices architectures.

You can install docker & docker compose here.

Cheatsheet

Docker Commands

  • docker run [OPTIONS] IMAGE [COMMAND] [ARG...]: Create a new container from an image and start a command or process in it.
  • docker build [OPTIONS] PATH: Build an image from a Dockerfile.
  • docker images [OPTIONS] [REPOSITORY[:TAG]]: List images in the local image cache.
  • docker ps [OPTIONS]: List running containers.
  • docker stop [OPTIONS] CONTAINER [CONTAINER...]: Stop a running container.
  • docker rm [OPTIONS] CONTAINER [CONTAINER...]: Remove one or more containers.
  • docker rmi [OPTIONS] IMAGE [IMAGE...]: Remove one or more images.
  • docker exec [OPTIONS] CONTAINER COMMAND [ARG...]: Run a command in a running container.
  • docker logs [OPTIONS] CONTAINER: Fetch the logs of a container.
  • docker pull [OPTIONS] NAME[:TAG|@DIGEST]: Pull an image or a repository from a registry.

Docker Compose Commands

  • docker-compose up [OPTIONS] [SERVICE...]: Create and start containers specified in the docker-compose.yml file.
  • docker-compose down [OPTIONS]: Stop and remove containers, networks, and volumes created by up.
  • docker-compose build [OPTIONS] [SERVICE...]: Build or rebuild services specified in the docker-compose.yml file.
  • docker-compose ps [OPTIONS] [SERVICE...]: List the running containers for services defined in the docker-compose.yml file.
  • docker-compose logs [OPTIONS] [SERVICE...]: Fetch the logs of containers for services defined in the docker-compose.yml file.
  • docker-compose exec [OPTIONS] SERVICE COMMAND [ARG...]: Run a command in a container for a service defined in the docker-compose.yml file.
  • docker-compose restart [OPTIONS] [SERVICE...]: Restart one or more containers for services defined in the docker-compose.yml file.
  • docker-compose stop [OPTIONS] [SERVICE...]: Stop one or more containers for services defined in the docker-compose.yml file.