How to set up a Docker Host
the simple way
client = Docker client
server = Docker Host
client is your computer (Mac, Linux, *BSD or other) where you have docker application installed, and you do your software development. Server is a Linux computer/server where you have dockerd and containerd and sshd installed and running.
However, if you do not have a docker installed on the client or server, please follow the next installation example. Otherwise, please skip to the configuration session.
Client install example (macOS)
brew install docker
Server install example (Arch Linux)
sudo su -
pacman -S docker, openssh
# to start services automatically:
systemctl enable sshd
systemctl enable docker
# start sshd
systemctl start sshd
Additional docker.service configuration can be found here
The Client computer has to connect to the Docker server via TCP. We’ll use SSH protocol to establish a connection between client and server, so that the client can manage the Docker host remotely and use its resources.
Docker needs to listen to the network, so we have to change docker service configuration.
Changing the ExecStart configuration
ExecStart=/usr/bin/dockerd -H tcp://192.168.1.10 -H fd://
Then start docker service.
sudo su -
# reload docker configuration
# start docker
systemctl start docker.service
The client has to be able to connect to the server via ssh. To better manage ssh sessions, (optionally) configure ssh key login.
To configure ssh key on the client-side:
then send the ssh public key to the server, by copying the public key from client to server.
without mention the -i parameter in the ssh-copy-id command, it will (by default) assume
Configure docker to use remote HOST resources, by setting
DOCKER_HOST environment variable:
To make it persistent:
echo 'export DOCKER_HOST=ssh://192.168.1.10' >> ~/.zshrc
## or, case you use bash
echo 'export DOCKER_HOST=ssh://192.168.1.10' >> ~/.bashrc
Run docker on client to check
Note that every deployment to this docker instance will be hosted and its ports published on the remote host.
So, when you run
docker run -it -p 8080:8080 app app
take in account that, port 8080 is published on 192.168.1.10 (in this example)