dockerd) on Linux. This guide covers systemd management, foreground debugging, socket tuning, remote access, TLS security, and persistent configuration.
Table of Contents
- Managing Docker with systemd
- Running the Daemon in Foreground
- Default Unix Socket
- Exposing the Daemon on TCP
- Securing the Daemon with TLS
- Persisting Configuration in daemon.json
- Flag vs Configuration File Conflicts
- References
Managing Docker with systemd
Use systemd to start, stop, and inspect the Docker service. By default, Docker is enabled to launch on boot.| Command | Description |
|---|---|
sudo systemctl start docker | Start the Docker service |
sudo systemctl stop docker | Stop the Docker service |
sudo systemctl restart docker | Restart the service |
sudo systemctl status docker | Show current status and logs |
sudo systemctl enable docker | Enable docker at startup |
sudo systemctl disable docker | Disable automatic startup |
If you make changes to
/etc/docker/daemon.json, restart Docker with sudo systemctl restart docker to apply them.Running the Daemon in Foreground
Troubleshoot or capture real-time logs by launchingdockerd interactively.
Foreground mode is ideal for capturing logs in CI pipelines or debugging startup failures.
Default Unix Socket
By default, Docker listens on a Unix domain socket. This restricts access to local clients only:- Socket path:
/var/run/docker.sock - Access: Local IPC (no remote connections)
DOCKER_HOST is overridden.
Exposing the Daemon on TCP
To allow remote management, binddockerd to both the Unix socket and a TCP port:
Port 2375 is unencrypted and unauthenticated. Exposing it publicly invites unauthorized access and potential malicious use. Only enable on secured networks or for testing.
Securing the Daemon with TLS
Encrypt and authenticate connections on port 2376 by enabling TLS:- Generate CA, server, and client certificates.
- Place
server.pemandserverkey.pemin a secure directory. - Start
dockerdwith TLS options:
Using TLS ensures confidentiality, integrity, and authentication for remote Docker API calls.
Persisting Configuration in daemon.json
Avoid long startup flags by defining options in/etc/docker/daemon.json:
Flag vs Configuration File Conflicts
Mixing CLI flags anddaemon.json entries can lead to startup errors: