A. New remote host
DOCKER_OPTS="-H tcp://0.0.0.0:2375"
sudo service docker restart
IMPORTANT: With systemd systems (trusty and vivid), we must add new file : /etc/systemd/system/docker.service.d/docker.conf with following content:
[Service] EnvironmentFile=-/etc/default/docker ExecStart= ExecStart=/usr/bin/docker -d $DOCKER_OPTS
And then restart socker.
Now, when trying :
docker ps
we’ll got error:
Get http:///var/run/docker.sock/v1.19/containers/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
That’s because docker client try to connect to file socket by default. So, from now, we must specify which host to connect to when running docker client. Like so :
docker -H localhost:2375 ps # or docker -H 127.0.0.1:2375 ps # or simply docker -H :2375 ps
Ok, but it’s annoying to specify the host all the time ! So, the solution is to define an environment variable DOCKER_HOST:
export DOCKER_HOST=0.0.0.0:2375
then we can just run :
docker ps
B. Local host
We must set environment variable DOCKER_HOST like following (assume host machien ip is 192.168.33.10)
export DOCKER_HOST=192.168.33.10:2375
C. transfer images from local docker host to remote docker host Now, to move all local images to the new docker host, we have to make it in three steps :
docker -H "" save -o /tmp/myimage.tar myimage
scp /tmp/myimage.tar user@192.168.33.10:/tmp/
docker load -i /tmp/myimage.tar
Hope this help