Configuring the Docker daemon for remote connectivity
In the previous recipes, we were using the Unix socket (/var/run/docker.sock
) to talk to the Docker engine. As mentioned earlier, by default dockerd
listens to the Unix socket /var/run/docker.sock
. However, access to the Unix socket is confined to a local system. But there will be use cases where you will have to access the Docker daemon remotely. You can achieve this by configuring the Docker daemon to listen for remote connections using the tcp
socket. In this recipe, we will configure our Docker daemon for remote API connectivity.
How to do it...
- Let's begin by locating the Systemd unit file for the Docker service using the
systemctl
command, as shown here:
$ sudo systemctl docker status | grep LoadedLoaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Evidently, /lib/systemd/system/docker.service
is the unit file for the Docker service. Here is the content of the default Docker service unit file:

As you...