1. Understanding where images come from
  2. Pulling a Docker image from Docker Hub
  3. Pushing a Docker image to Docker Hub

Log into the Docker Hub from the command line

$docker login --username=yourhubusername --password yourpassword
docker login
docker login

Getting an image from Docker Hub

We get docker image of  : example-go-rest-api Source code from here

If you just want to pull the image but not run it, you can also do

$ docker pull fkautz/example-go-rest-api
docker pull
docker pull output result
docker pull output result
$ docker run -p 8080:8083 fkautz/example-go-rest-api

Getting an image to Docker Hub

Check the image ID using :

$ docker images

and tag your image

$ docker tag 4ab4c602aa5e mydockerreddah/hello-world:firsttry
docker tag

Push your image to the repository you created

$ docker push mydockerreddah/hello-world

Your image is now available for everyone to use.

Saving and loading images

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

  1. Bandwidth many ISPs have much lower upload bandwidth than download bandwidth.
  2. Unless you’re paying extra for the private repositories, pushing equals publishing.
  3. 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
Error message : If when you log yo docker hub and you get the following error message:
error getting credentials - err: exit status 1, out: `GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files`
Install the following Packages in ubuntu to fixe the issue

sudo apt install gnupg2 pass