See this issue.
Docker best practise to Control and configure Docker with systemd.
-
Create
daemon.json
file in/etc/docker
:{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
-
Add
/etc/systemd/system/docker.service.d/override.conf
[Service] ExecStart= ExecStart=/usr/bin/dockerd
-
Reload the systemd daemon:
systemctl daemon-reload
-
Restart docker:
systemctl restart docker.service
on Ubuntu 22.04.3 couldn't get it to work with these instructions... do this:
Update Docker Configuration:
Edit the Docker daemon configuration file. The configuration file is typically located at /etc/docker/daemon.json. If it doesn't exist, you can create it.
sudo nano /etc/docker/daemon.json
Add the following content to the file:
{
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2375"]
}
This configuration tells Docker to listen on both the UNIX socket and a TCP socket on all available network interfaces (0.0.0.0) on port 2375.
Restart Docker:
After making changes to the Docker daemon configuration, you need to restart the Docker daemon for the changes to take effect.
sudo systemctl restart docker
Adjust Firewall Rules (if necessary):
If you have a firewall enabled on your Ubuntu server, make sure to allow traffic on the Docker daemon port (default is 2375). You can use ufw (Uncomplicated Firewall) to do this:
bash
sudo ufw allow 2375