Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

How to push Docker Image to Docker Hub Registry?

3 min read

This is step by step guide on how to push Docker Image to Docker Hub registry. To get started with this post, I assume that you are well familiar with Docker , Docker specific commands and utilities. If not, visit Getting Started with Docker – Part1 to get started with Docker CLIs.

I assume you have already pulled Ubuntu 12.04 image from the remote docker hub and it is currently running as Docker container as shown below:

[simterm] [root@localhost ~]# docker ps
ee9aa6c9b0bb ubuntu:12.04 “/bin/bash” 36 minutes ago
Up 36 minutes hungry_ptolemy
[/simterm] [simterm] You can run the below command to get detail information of the container:

[simterm] [root@localhost ~]# docker inspect ee9aa6
“AppArmorProfile”: “”,
“Args”: [],
“Config”: {
“AttachStderr”: true,
“AttachStdin”: true,
“AttachStdout”: true,
“Cmd”: [
“CpuShares”: 0,
“Cpuset”: “”,
“Domainname”: “”,
“Entrypoint”: null,
“Env”: null,
“ExposedPorts”: null,
“Hostname”: “ee9aa6c9b0bb”,
“Image”: “ubuntu:12.04”,
“MacAddress”: “”,
“Memory”: 0,
“MemorySwap”: 0,
“NetworkDisabled”: false,
“OnBuild”: null,
“OpenStdin”: true,
“PortSpecs”: null,
“StdinOnce”: true,
“Id”: “ee9aa6c9b0bb9312851cc1c8775921eba45d56d0f3ba42c1e0a0b2af92a70df9”,
“MountLabel”: “”,
“Name”: “/hungry_ptolemy”,
“NetworkSettings”: {
“Bridge”: “docker0”,
“Gateway”: “”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“IPAddress”: “”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“LinkLocalIPv6Address”: “fe80::42:acff:fe11:b”,
“LinkLocalIPv6PrefixLen”: 64,
“MacAddress”: “02:42:ac:11:00:0b”,
“PortMapping”: null,
“Ports”: {}
“Path”: “/bin/bash”,
“ProcessLabel”: “”,



Enter into the Docker image as shown below:

[simterm] [root@localhost ~]# docker run -it collabnix/puppet4docker:latest /bin/bash

Now let’s install software into the container. Say, I want to configure Puppet into the container to orchestrate the docker container itself.

[simterm] root@eedc8a990076:/# apt-get install puppet

root@eedc8a990076:/#cd /etc/puppet/modules

root@eedc8a990076:/etc/puppet/modules# wget https://forgeapi.puppetlabs.com/v3/files/garethr-docker-4.0.2.tar.gz –no- check-certificate
–2015-05-19 06:47:44– https://forgeapi.puppetlabs.com/v3/files/garethr- docker-4.0.2.tar.gz
WARNING: cannot verify forgeapi.puppetlabs.com’s certificate, issued by `/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA – G2′:
Unable to locally verify the issuer’s authority.
Proxy request sent, awaiting response… 200 OK
Length: unspecified [application/octet-stream]
Saving to: `garethr-docker-4.0.2.tar.gz’

[ <=> ] 34,484 –.-K/s in 0.05s

2015-05-19 06:47:46 (636 KB/s) – `garethr-docker-4.0.2.tar.gz’ saved [34484]

root@eedc8a990076:/etc/puppet/modules# tar xvzf garethr-docker-4.0.2.tar.gz
root@eedc8a990076:/etc/puppet/modules# mv garethr-docker-4.0.2 docker

Let’s configure Puppet to include Docker class as shown below:

[simterm] #vi /etc/puppet/manifests/site.pp

include ‘docker’

Save the file.

You can now restart the puppet service as shown below:

[simterm] root@eedc8a990076:/etc/puppet# service puppet restart
* Restarting puppet agent [ OK ]

So our application is ready. It’s time to push this image to the remote Docker hub.

Docker Commit:

Before pushing the image to Docker Hub registry, the image need to be committed just like git commit.We can commit a copy of this container to an image using the docker commit command.

[simterm] [root@localhost ~]# docker commit -m “Puppet for Docker” -a “Ajeet Raina” eedc8a990076 collabnix/puppet-for-docker:v1.0

As shown above, we’ve specified two flags: -m and -a.

The -m flag allows us to specify a commit message, much like you would with a commit on a version control system. The-a flag allows us to specify an author for our update.

We can then commit a copy of this container to an image using the docker commit command.

We’ve also specified the container we want to create this new image from,  eedc8a990076(the ID we recorded earlier) and we’ve specified a target for the image:It consists of a  user, collabnix, that we’re writing this image to. We’ve also specified the name of the image, here we’re keeping the original image name puppet-for-docker. Finally we’re specifying a tag for the image: v1.0.

First, let us authenticate ourself to Dockerhub:

[simterm] #docker login

You will need Dockerhub credentials to login successfully.

Next, its time to push it to the remote Docker hub. Let’s do it quick:

[simterm] [root@localhost ~]# docker push collabnix/puppet-for-docker:v1.0
The push refers to a repository [collabnix/puppet-for-docker] (len: 1)
Sending image list
Pushing repository collabnix/puppet-for-docker (1 tags)
c50f7e0846e6: Image already pushed, skipping
fd248b999044: Image already pushed, skipping
9f91f850df24: Image already pushed, skipping
ac6b0eaa3203: Image already pushed, skipping
abb227dc9aed: Image successfully pushed
Pushing tag for rev [abb227dc9aed] on {https://cdn-registry-
[root@localhost ~]#

Finally, we have pushed it to the remote Docker hub. Let’s verify.

Verifying the Image:
To verify the content, lets try to pull it on another machine:

[simterm] [root@puppetmastr ~]# docker search puppet-for-docker
INFO[0130] GET /v1.18/images/search?term=puppet-for-docker
INFO[0130] +job search(puppet-for-docker)


Pulling the Image:

[simterm] #docker pull collabnix/puppet-for-docker

abb227dc9aed: Pulling fs layer
c50f7e0846e6: Download complete
fd248b999044: Download complete
9f91f850df24: Download complete
ac6b0eaa3203: Download complete

Just awesome. So,we finally learnt how to push our image to Dockerhub.

Did you find this blog helpful?  Feel free to share your experience. Get in touch @ajeetsraina

If you are looking out for contribution/discussion, join me at Docker Community Slack Channel.

Know more about the latest Docker releases clicking on this link.

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

Leave a Reply

Your email address will not be published.