Exposing your Docker Host should follow these steps:
#1. create the following directory if it doesn't exist
sudo mkdir -p /etc/systemd/system/docker.service.d
#2. create options.conf
configuration file with the following content
sudo nano /etc/systemd/system/docker.service.d/options.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375
#3. reload the systemd
daemon
sudo systemctl daemon-reload
#4. restart docker
sudo systemctl restart docker
If you want to have an encrypted connection, then you should replace port 2375 with 2376, and set up certificates
and daemon.json
configuration files in /etc/docker/certs/
and /etc/docker/daemon.json
. Example:
{
"tlsverify": true,
"tlscacert": "/etc/docker/certs/ca-cert.pem",
"tlscert": "/etc/docker/certs/server-cert.pem",
"tlskey": "/etc/docker/certs/server-key.pem",
"host": "tcp://0.0.0.0:2376"
}