Reputation: 885
Background
There is a private docker registry I have no control of. This registry is not accessible from my computer but is accessible from a remote server I have access to.
This is my current (quite inefficient) workflow:
# On my machine
$ docker save IMAGE > FILE
$ scp FILE SERVER
$ ssh SERVER
# On the server
$ docker load < FILE
$ docker tag -f IMAGE REGISTRY:5000/IMAGE
$ docker push REGISTRY:5000/IMAGE
Problem
It takes forever to push the image as I need to save, upload and load the whole tarball even if there are no changes in most of the docker layers.
I tried to use ssh to forward the docker registry port (5000) to a port on my machine:
$ ssh -L 5042:REGISTRY:5000 SERVER
Now I can communicate with the registry from my machine:
$ curl localhost:5042/v2/
{}
But the docker wont push images to it:
$ docker tag IMAGE localhost:5042/IMAGE
$ docker push localhost:5042/IMAGE
The push refers to a repository [localhost:5042/IMAGE] (len: 1)
Sending image list
FATA[0000] Put http://localhost:5042/v1/repositories/IMAGE/: dial tcp 127.0.0.1:5042: connection refused
I have a feeling that the problem is in different name/tag of the image. On the server I need to tag it as REGISTRY:5000/IMAGE
but on localhost it would make no sense as the REGISTRY
url is not accessible from my computer.
Or the problem may be caused by the fact that I am running docker through docker-machine.
Question
Can I somehow push to a private docker registry that is port-forwarded to a local port?
Upvotes: 5
Views: 2539
Reputation: 885
There need to be two ssh tunnels. One from the local machine (this one is used by the docker client) and one from the docker-machine (this one is used by docker daemon).
docker-machine ssh
ssh -L 5042:REGISTRY:5000 SERVER
Upvotes: 4