Containers 101 – Push containers to Dockerhub

So you created your first container and now you want to share it with the world or be able to pull it from any machine with Docker client running? In this lesson we will setup a repository on DockerHub and push our container to it. For vSphere folks, DockerHub is very similar to a VM template library.

Pre-Reqs: 

  • A Machine Running Docker see my guide here
  • A container image to push, see my guide here

Signup for a DockerHub account, it’s free!

 

Login to DockerHub and click Create Repository

 

Enter name and details and click create

  1. Enter a name for the new repository
  2. Enter a description
  3. Click Create
 

Notice it is empty as it has no containers

 

Let’s push your container to this repository. List the local images with the following command

docker images
 

Login to DockerHub with the following command and enter your docker id and password

docker login
 

Run the following command to tag your local image as a docker repository image, NOTE: the item in red should be your docker id

docker tag webserver:latest vmtocloud/webserver:latest
 

Push the image to DockerHub with the following command NOTE: It may take several minutes to complete uploading

docker push vmtocloud/webserver:latest
 

Refresh the dockerhub page and see that your new container got uploaded

 

Now from any machine running docker or Kubernetes you can run the container with the following

docker run -d -p 80:80 vmtocloud/webserver
 

One thing to note though is that DockerHub is rate limited, meaning if there are over 100 pulls a day from the same source IP you have to wait a day and the error you get is not real helpful in Kubernetes. Read more about this and how to get around it here. You can also use VMware’s free Harbor Registry to build your own docker hub. 

Remember sharing is caring!

One Reply to “Containers 101 – Push containers to Dockerhub”

  1. Pingback: Containers 101 – Create a Contaner with Docker | VMtoCloud.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.