๐ Docker Summary Guide
๐ Docker Summary Guide
I. What is Docker?
Docker is a platform for developing, shipping, and running applications in lightweight, portable containers. Containers package code and dependencies together so applications run reliably across different environments.
II. Core Concepts
-
ImageA lightweight, standalone, immutable file that includes the application and all its dependencies.
-
ContainerA runnable instance of an image. Containers are isolated from the host and each other.
-
DockerfileA script used to build Docker images. It contains instructions (like
FROM
,RUN
,COPY
, etc.). -
Docker EngineThe core client-server application:
-
Docker Daemon (
dockerd
): Runs in the background. -
Docker CLI (
docker
): Command-line interface to interact with Docker.
-
-
Docker Hub / RegistryCentral repositories where Docker images are stored and shared.
-
Docker Hub is the default public registry.
-
III. Docker Architecture
-
Docker ClientThe user interface to Docker. Sends commands to the daemon (via REST API).
-
Docker DaemonManages Docker objects (images, containers, networks, volumes). Listens on a socket.
-
Docker Objects
-
Images
-
Containers
-
Networks
-
Volumes
-
IV. Dockerfile Instructions (Key Commands)
Instruction | Description |
---|---|
FROM |
Base image to start with. |
RUN |
Executes command during image build. |
COPY / ADD |
Copy files into the image. |
CMD |
Default command when a container runs. |
ENTRYPOINT |
Sets the main executable. |
EXPOSE |
Documents port(s) the container listens on. |
ENV |
Sets environment variables. |
WORKDIR |
Sets the working directory inside the container. |
V. Container Lifecycle
-
CreateUsing
docker create
ordocker run
. -
Start / StopUse
docker start
/docker stop
. -
Pause / UnpauseTemporarily suspend or resume.
-
Restart / RemoveManage lifecycle and cleanup.
VI. Docker Networking
-
Bridge Network (default)Containers get an IP on a private network; NAT used for external access.
-
Host NetworkContainer shares the host network.
-
Overlay NetworkUsed in Docker Swarm for multi-host communication.
-
NoneNo network access for the container.
VII. Docker Storage
-
Volumes
-
Managed by Docker. Persistent storage.
-
Shared between containers.
-
-
Bind Mounts
-
Mount a file/folder from the host into the container.
-
-
tmpfs Mounts
-
Temporary filesystems stored in memory.
-
VIII. Docker Compose
Docker Compose is a tool to define and run multi-container applications using a docker-compose.yml
file.
-
Define services, networks, volumes.
-
Use
docker-compose up
to start everything. -
Ideal for local development and testing environments.
IX. Docker Swarm (Optional: Native Orchestration)
Docker Swarm is Docker's built-in container orchestration tool.
-
Turns multiple Docker engines into a single cluster.
-
Manages container deployment, scaling, load-balancing.
-
Use
docker swarm init
to start a swarm.
X. Docker Best Practices
-
Keep images small using minimal base images (
alpine
). -
Use
.dockerignore
to exclude files from builds. -
Minimize layers in Dockerfile.
-
Avoid running containers as root inside.
-
Use multistage builds for cleaner production images.
Comments
Post a Comment