Docker: Push Image

From Glitchdata
Jump to navigation Jump to search
  • Push an image to a repo
    • docker push <image_name>
    • this will most likely fail
    • By default, it interacts with Docker Hub
  • Docker: Registry Login into the Docker Hub from the command line
    • docker login --username=yourhubusername --email=youremail@company.com
  • Create the Repo on Docker Hub
    • Use web interface and click "Create"
  • The local image and remote image need to match
    • docker tag <image_name> <docker_hub_name>/<image_name>
    • docker push <docker_hub_name>/<image_name>


Saving and loading images

Pushing to Docker Hub is great, but it does have some disadvantages:

  • Bandwidth - many ISPs have much lower upload bandwidth than download bandwidth.
  • Unless you’re paying extra for the private repositories, pushing equals publishing.
  • When working on some clusters, each time you launch a job that uses a Docker container it pulls the container from Docker Hub, and if you are running many jobs, this can be really slow.
  • Solutions to these problems can be to save the Docker container locally as a a tar archive, and then you can easily load that to an image when needed.

To save a Docker image after you have pulled, committed or built it you use the docker save command. For example, lets save a local copy of the verse_gapminder docker image we made:

docker save verse_gapminder > verse_gapminder.tar

If we want to load that Docker container from the archived tar file in the future, we can use the docker load command:

docker load --input verse_gapminder.tar


Related