Push to port-forwarded docker registry

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.

  • deploying nodejs on docker
  • Docker + GNU Screen lags
  • Communication with Spark using Spark JobServer in docker
  • When Docker image push on my linux machine unauthorized: authentication required error display
  • How do I serve static files from either gunicorn or nginx
  • Unable to connect to mongodb in docker container
  • 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?

  • Docker Toolbox setup fails on Windows 8.1
  • docker for windows mount a folder but can't open it after several hours
  • Elastic Beanstalk Django Deployment With Preconfigured Docker Container
  • Best way to manage docker containers with supervisord
  • AspnetPublishHandler with name “Custom” was not found when publishing ASP.NET 5 project to Docker
  • Best way to transfer data to named volume of Docker
  • One Solution collect form web for “Push to port-forwarded docker registry”

    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
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.