migrate local docker images to a remote docker host

migrate local docker images to a remote docker host

A. New remote host
– install docker
– setup simple configuration to let docker daemon be accessible from other machines:
Edit /etc/default/docker, and add following line

DOCKER_OPTS=”-H tcp://″

– restart docker daemon

sudo service docker restart

With systemd systems (trusty and vivid), we must add new file :
with following content:

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


then we can just run :

docker ps

B. Local host

We must set environment variable DOCKER_HOST like following (assume host machien ip is


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 :
1. under local machine: export images as tar files

docker -H “” save -o /tmp/myimage.tar myimage

2. transfer tar files from local machine to the remote one (with scp for example)

scp /tmp/myimage.tar user@

3. under remote machine: load images

docker load -i /tmp/myimage.tar

Hope this help


Leave a Reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax