About
The Docker daemon (dockerd) 1) is the hypervisor background process that the docker cli command is calling under the hood.
It's
- a runtime for containers.
- a background service running on the host that manages building, running and distributing Docker containers.
The daemon creates and manages Docker objects, such as:
- and volumes.
The Docker daemon (dockerd) listens for Docker API requests. A daemon can also communicate with other daemons to manage Docker services.
Management
Connection
Env
The Docker daemon can listen for Docker Engine API requests via three different types of Socket 2)
Locally:
- unix socket: (Docker Desktop creates a symlink to the socket during installation)
- Linux, Mac, and other Unix platforms: unix:///var/run/docker.sock
- Windows npipe:////./pipe/docker_engine
dockerd -H unix:///var/run/docker.sock
- fd: systemd socket activation
Remotely: tcp
dockerd -H tcp://0.0.0.0:2375
You can modify Docker connection using the following environment variables:
- DOCKER_HOST to set the –H flag
export DOCKER_HOST="tcp://0.0.0.0:2375"
- DOCKER_TLS_VERIFY to set the –tlsverify flage. To enable or disable TLS verification; off by default.
- DOCKER_API_VERSION: to set the version of the API to reach, leave empty for latest.
- DOCKER_CERT_PATH: to load the TLS certificates from.
Inside a container
If you have the docker cli inside a container that must call the host daemon, you need to mount the socket.
Example:
- In a Dockerfile, you can mount it as a volume
VOLUME ["/var/run/docker.sock"]
- When creating an container with the RUN command
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock image-with-docker:latest bash
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock docker:latest bash
# then from inside
# docker run --rm -d nginx
Start / Stop
Docker Engine (dockerd)
Windows Service
- Windows: Windows - Services
net stop com.docker.service
The Docker for Windows Service service is stopping.
The Docker for Windows Service service was stopped successfully.
net start com.docker.service
The Docker for Windows Service service is starting.
The Docker for Windows Service service was started successfully.
- Linux: Systemd: https://docs.docker.com/config/daemon/systemd/