All technological notes.
images
application and required envrionment
application will use and additional metadata
registries
containers
Docker Client (CLI / API)
↓
Docker Daemon (dockerd)
↓
Container Runtime (containerd → runc)
↓
Containers (isolated processes)
dockerd)
containerd: manages container lifecyclerunc: actually creates the container using Linux kernel featuresprocesses (not full VMs)Namespaces (isolation)
cgroups (resource control)
docker run -d nginxDocker does:
CLI sends requestDaemon checks image locally
read-write layernamespaces:
PID namespace: Process identifiers and capabilitiesIPC namespace: Process communication over shared memoryUTS namespace: Host and domain nameNET namespace: Network access and structureUSR namespace: User names and identifiersMNT namespace: Filesystem access and structurecgroupsrunc starts the processlinux namespaceLinux Namespaces
Mount namespace (mnt): isolates mount points (file systems).Process ID namespace (pid): isolates process IDs.Network namespace (net): isolates network devices, stacks, ports, etc.Inter-process communication namespace (ipc) isolates the communication between processes (this includes isolating message queues, shared memory, and others).UNIX Time-sharing System (UTS) namespace isolates the system hostname and the Network Information Service (NIS) domain name.User ID namespace (user): isolates user and group IDs.Time namespace: allows each container to have its own offset to the system clocks.Cgroup namespace: isolates the Control Groups root directory.# ubuntu
docker run -d --name busybox busybox sleep 300
# 8ef189a2907c47d349cc5c52f0bae3d8c7a611fc9f562e994a99eb83752c82fe
# host
pstree
# systemd─┬─2*[agetty]
# ├─containerd───14*[{containerd}]
# ├─containerd-shim─┬─sleep
# │ └─10*[{containerd-shim}]
ps aux | grep sleep
# root 681 0.0 0.0 4436 1716 ? Ss 20:16 0:00 sleep 300
ip a
# 3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
# link/ether 06:7b:a3:c8:28:94 brd ff:ff:ff:ff:ff:ff
# inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
# valid_lft forever preferred_lft forever
# inet6 fe80::47b:a3ff:fec8:2894/64 scope link
# valid_lft forever preferred_lft forever
# in container
docker exec -it busybox sh
# / #
ps -a
# PID USER TIME COMMAND
# 1 root 0:00 sleep 300
# 7 root 0:00 sh
# 15 root 0:00 ps -a
ip a
# 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
# link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
# inet 127.0.0.1/8 scope host lo
# valid_lft forever preferred_lft forever
# inet6 ::1/128 scope host
# valid_lft forever preferred_lft forever
# 2: eth0@if4: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
# link/ether ea:13:d6:12:07:d0 brd ff:ff:ff:ff:ff:ff
# inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
# valid_lft forever preferred_lft forever
cgroupsLinux Control Groups (cgroups)
processes into hierarchical groups to manage and limit system resources like CPU, memory, disk I/O, and network bandwidth,
docker run --cpuset-cpus="1,2": only use cores one and twodocker run --cpus="0.5": only half of a CPU coredocker run --memory="100m": set the maximum memory sizesyscallsystem call (syscall)
privileged service (e.g., writing to a file).system call, causing a controlled switch from User Mode (limited privileges) to Kernel Mode (full privileges).kernel returns control and data to the user program, switching back to User Mode.docker run --privilegedcreate a privileged containerLinux capabilitiesLinux capabilities
root (superuser) privileges into smaller, distinct units of permission.Principle of Least Privilege:
CAP_SYS_ADMIN:
CAP_NET_BIND_SERVICE:
CAP_NET_RAW:
CAP_CHOWN:
CAP_DAC_OVERRIDE:
CAP_KILL:
| CMD | DESC |
|---|---|
getcap FILE |
Displays the capabilities assigned to files (file capabilities). |
setcap FILE |
Assigns capabilities to an executable file. |
getpcaps |
Shows the capabilities of a currently running process. |
docker run -d --name busybox busybox sleep 300
ps -aux | grep sleep
# root 1569 0.0 0.0 4436 1652 ? Ss 21:33 0:00 sleep 300
getpcaps 1569
# 1569: cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap=ep
Capabilities can be added or removed (dropped) from a container when you create it.
processes in the container.Seccomp (secure computing mode)Seccomp (secure computing mode)
system calls (syscalls) a process can make, thereby reducing the attack surface of an application.Docker, containerd, and CRI-O ship with default seccomp profiles that block around 40+ dangerous syscalls by default while allowing common ones.| Command | Description |
|---|---|
docker system info |
Display system-wide information |
docker system df |
Show disk usage (images, containers, volumes) |
docker system prune |
Remove unused data (containers, networks, dangling images) |
docker system prune -a |
Remove all unused images (not just dangling) |
docker system prune -a --volumes |
Aggressive cleanup (includes volumes ⚠️ data loss risk) |
docker volume ls |
List volumes |
docker volume rm <volume> |
Remove a volume |
docker volume prune |
Remove unused volumes |
docker network ls |
List networks |
docker network prune |
Remove unused networks |
docker inspect <container/image> |
Show detailed metadata (JSON) |
docker logs <container> |
View container logs |
docker exec -it <container> /bin/bash |
Enter a running container |
docker top <container> |
Show running processes inside container |
docker stats |
Real-time CPU/memory usage of containers |
Docker orchestration
While Docker Engine handles individual containers, orchestration tools are required to coordinate complex, multi-container applications in production environments.
Scheduling:
Scaling:
Health Monitoring:
Service Discovery & Load Balancing:
DNS names to services and distributing incoming traffic across healthy container instances.Kubernetes (k8s):
horizontal auto-scaling, self-healing (restarting failed containers), and automated rollouts.Docker Swarm:
Docker CLI commands to manage a swarm of nodes.Docker Compose:
Rootless Docker
user space| Feature | Root Docker | Rootless Docker |
|---|---|---|
| Daemon privilege | root | non-root |
| Security risk | higher | lower |
| Performance | native | slightly slower |
| Networking | full | limited |
| Port binding | any port | >1024 only |