How to set up a Docker Host

the simple way

client = Docker client
server = Docker Host

So that
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 -Syu
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.

## server

Docker needs to listen to the network, so we have to change docker service configuration.

vim /lib/systemd/system/docker.service

Changing the ExecStart configuration

ExecStart=/usr/bin/dockerd -H tcp:// -H fd://

Then start docker service.

sudo su -
# reload docker configuration
systemctl daemon-reload
# 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.

ssh-copy-id <user>@

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 environment variable:

export DOCKER_HOST=ssh://

To make it persistent:

echo 'export DOCKER_HOST=ssh://' >> ~/.zshrc 
## or, case you use bash
echo 'export DOCKER_HOST=ssh://' >> ~/.bashrc

Run docker on client to check

docker ps

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 (in this example)

That’s it!

System Architect