SyntaxStudy
Sign Up
Docker Docker Architecture and Key Concepts
Docker Beginner 1 min read

Docker Architecture and Key Concepts

Docker uses a client-server architecture. The Docker CLI sends commands to the Docker daemon (dockerd) over a UNIX socket or TCP. The daemon manages images, containers, networks, and volumes. Docker Desktop bundles the daemon, CLI, and a lightweight Linux VM on macOS and Windows. Images are built from layers. Each instruction in a Dockerfile produces a read-only layer. Layers are cached and reused across builds and between images that share a common base. When you run a container, Docker adds a thin writable layer on top of the image layers. All changes during the container's lifetime live in this writable layer and are discarded when the container is removed unless data is stored in a volume. Container namespaces (PID, network, mount, UTS, IPC) provide the isolation; cgroups limit resource consumption (CPU, memory, I/O). Understanding that containers share the host kernel means kernel exploits can potentially escape the container. Docker is not a security boundary equivalent to a VM, and root inside a container has elevated privileges. Dropping capabilities and running as a non-root user reduces this risk.
Example
# Inspect image layers
docker history node:20-alpine

# Run and inspect a container
docker run -d --name webserver -p 8080:80 nginx:alpine
docker inspect webserver
docker inspect webserver --format '{{.NetworkSettings.IPAddress}}'
docker stats webserver --no-stream
docker top  webserver

# Exec into a running container
docker exec -it webserver sh
docker exec webserver nginx -t

# Copy files to/from containers
docker cp webserver:/etc/nginx/nginx.conf ./nginx.conf
docker cp ./index.html webserver:/usr/share/nginx/html/index.html

# Container lifecycle
docker pause   webserver
docker unpause webserver
docker restart webserver
docker logs    webserver --tail 50 --follow

# Clean up
docker stop webserver && docker rm webserver