How to copy Docker images from one host to another without using a repository

前端 未结 15 1812
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 13:37

How do I transfer a Docker image from one machine to another one without using a repository, no matter private or public?

I create my own image in VirtualBox, and wh

15条回答
  •  时光说笑
    2020-11-22 14:14

    docker-push-ssh is a command line utility I created just for this scenario.

    It sets up a temporary private Docker registry on the server, establishes an SSH tunnel from your localhost, pushes your image, then cleans up after itself.

    The benefit of this approach over docker save (at the time of writing most answers are using this method) is that only the new layers are pushed to the server, resulting in a MUCH quicker upload.

    Oftentimes using an intermediate registry like dockerhub is undesirable, and cumbersome.

    https://github.com/brthor/docker-push-ssh

    Install:

    pip install docker-push-ssh
    

    Example:

    docker-push-ssh -i ~/my_ssh_key username@myserver.com my-docker-image

    The biggest caveat is that you have to manually add your localhost to Docker's insecure_registries configuration. Run the tool once and it will give you an informative error:

    Error Pushing Image: Ensure localhost:5000 is added to your insecure registries.
    More Details (OS X): https://stackoverflow.com/questions/32808215/where-to-set-the-insecure-registry-flag-on-mac-os
    

    Where should I set the '--insecure-registry' flag on Mac OS?

提交回复
热议问题