One Pager Cheat Sheet
- This article provides common interview questions and insights on Docker, a containerization tool used for developing, deploying, and managing applications known for its portability, efficiency, consistency, and security.
- Docker is an open-source platform for containerization, allowing developers to package applications and dependencies into portable containers that can be easily moved and deployed across different environments, with a client-server architecture that uses a Docker client to interact with the Docker daemon.
- Docker containers are not limited to running only Linux programs or executables, as Docker uses containerization technology to create a portable and isolated environment that can run various types of applications, including Linux and Windows-based applications with their dependencies, while offering a level of abstraction from the underlying infrastructure, and a client-server architecture that enables developers to create, run, and test applications on any platform before deploying them to production environments.
- The main advantages of Docker include portability, efficiency, security, consistency, and collaboration while its disadvantages are a steep learning curve, increased complexity, dependency management challenges, and compatibility issues with existing programs.
- A Docker container is a self-contained package that contains everything required to run a program, built using Docker images, and separated from the underlying infrastructure and other containers for consistency and security in different environments, which virtualizes at the app layer unlike virtual machines.
- A Docker image is an executable package for building Docker containers that has everything needed to run software, generated using a Dockerfile and saved in registries like Docker Hub for easy distribution and deployment.
- A Dockerfile is a script that gives instructions for building a Docker image with information on software installation, data copying, and configuration, used with the
Docker build command
to construct images for Docker containers. - Docker has three components, including the Docker Client, Docker Host, and Docker Registry, with the Docker Client executing "build" and "run" operations to communicate with the Docker Host, which contains the primary Docker daemon and hosts containers and images, and images are stored in the Docker Registry, such as Docker Hub or Docker Cloud.
- Both virtualization and containerization create separate environments for executing programs, but they differ in terms of their implementation and resource utilization.
- The lifecycle of a Docker container involves five phases from creation to termination, including the Created, Running, Paused, Stopped, and Deleted states.
- A Docker registry is a central storage system for Docker images which serve as the foundation to create Docker containers and can be either public or private, hosted on-premises or in the cloud, with one of the most commonly used public registries being Docker Hub.
- The article lists essential Docker commands including Build, Create, Dockerd, Info, and Kill.
- When a Docker container is in a "Paused" state, all processes inside the container have been paused and it can only transition to the stopped state after being
resumed
with theunpause
command. - The
docker ps
command outputs all running containers in Docker. - The
sudo docker stop
command stops a running Docker container by specifying the container name. - The
Docker daemon
is responsible for managingDocker
containers and images, initialized and started using thedockerd
command, which requiresroot privileges
and may need to be configured as a service for automatic startup.