Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Docker Hub: Save and Share Your Docker Images

DZone's Guide to

Docker Hub: Save and Share Your Docker Images

See how you can set up your Docker Hub account to save your images as well as share them around. Also see how you can use webhooks to create automated builds.

· Cloud Zone
Free Resource

Are you joining the containers revolution? Start leveraging container management using Platform9's ultimate guide to Kubernetes deployment.

The Docker Hub is a cloud-based registration service for the construction of container applications or services.

It provides a centralized resource for image container discovery, distribution, and change management, as well as user and team collaboration and workflow automation throughout the development pipeline.

Docker Hub provides the following features:

Image repository : Find, manage and push and pull of community images, official and private image libraries.

Automated build : Automatically create new images when you make changes to a code that is on GitHub or bit bucket.

Webhooks: A feature of automated builds, webhooks let you trigger actions after a successful push to a repository.

Organization: Create working groups to manage user access to repositories of images.

Steps

1. Public repository:

It's a list of all images available on the public repository.

2. Here, I got an existing image:



3. I logged in my Docker hub account:

Image title

4. I tagged it to send the image to my account:

Image titleNow I have two images, the original and my own version.

5. In the end, I pushed to the repository:

Image title

6. If I check my Docker Hub account, I can see the image I sent.

Image title


Webhooks

The webhook is an HTTP callback triggered by a specific event.
You can use a webhook to notify people, services, and other applications after a new image is sent to your repository. 

To start adding webhooks, scroll to the desired repository in the Hub and click "Webhooks" under the "Settings" box. The webhook is called only after a successful push is made.

Call webhooks are HTTP POST requests with a JSON payload similar to the example shown below.

Image title


After I create my webhook, I will see the following:

Image title


Just to test this webhook, I used this site: http://requestb.in.

Image title


This site will provide one URL for the webhook URL abd provides another URL to check the request:

Image title

Automated Build

You can build your images automatically from a compilation context stored in a repository. A building context is a Dockerfile and any files in the specific location.

For an automated build, the building context is a repository where it sends a Dockerfile. The use of automated builds requires that you have an account on Docker Hub and a hosted repository provider on GitHub or BitBucket.

If you already have on your Github or BitBucket account, you must have chosen the type of public and private connection.

Image title

Image title

Image titleImage title


After each commit is mapped, it is possible to see a table with the status of each image build with the code committed. 

Image title

And it is possible to combine an automated build with webhooks, the result of which can be deployed.

Image title


These functionalities for webhooks and automated building are limited in private mode. Each user has one private repo and parallel build, and this pipeline does not happen immediately for free accounts.

For more information, take a look at my slides.

Using Containers? Read our Kubernetes Comparison eBook to learn the positives and negatives of Kubernetes, Mesos, Docker Swarm and EC2 Container Services.

Topics:
docker ,docker hub ,devops ,automation

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}