Files
oam/knowledge base/docker.md
2022-05-11 12:31:33 +02:00

1.9 KiB

Docker

TL;DR

# Create containers.
docker create -h alpine-test --name alpine-test alpine

# Start containers.
docker start alpine-test

# Create and start containers.
docker run hello-world
docker run -ti --rm alpine cat /etc/apk/repositories
docker run -d --name boinc --network=host --pid=host -v "boinc:/var/lib/boinc" \
  -e BOINC_GUI_RPC_PASSWORD="123" -e BOINC_CMD_LINE_OPTIONS="--allow_remote_gui_rpc" \
  boinc/client

# Gracefully stop containers.
docker stop alpine-test

# Kill containers.
docker kill alpine-test

# Restart containers.
docker restart alpine-test

# Show containers' status.
docker ps
docker ps --all

# Show containers' output.
docker log alpine-test

# List processes running inside containers.
docker top alpine-test

# Show information on containers.
docker inspect alpine-test

# Cleanup.
docker rm -f alpine-test
docker rmi alpine
docker system prune -a

Daemon configuration

The docker daemon is configured using the /etc/docker/daemon.json file:

{
    "default-runtime": "runc",
    "dns": ['8.8.8.8', '1.1.1.1']
}

Containers configuration

Docker mounts specific system files in all containers to forward its settings:

6a95fabde222$ mount
…
/dev/disk/by-uuid/1bb…eb5 on /etc/resolv.conf type btrfs (rw,…)
/dev/disk/by-uuid/1bb…eb5 on /etc/hostname type btrfs (rw,…)
/dev/disk/by-uuid/1bb…eb5 on /etc/hosts type btrfs (rw,…)

Those files come from the volume the docker container is using for its root, and are modified on the container's startup with the information from the CLI, the daemon itself and, when missing, the host.

Sources