2015-06-08 03:07:20 +00:00
<!-- [metadata]>
+++
title = "Get started with Docker Hub"
description = "Learn how to use the Docker Hub to manage Docker images and work flow"
keywords = ["repo, Docker Hub, Docker Hub, registry, index, repositories, usage, pull image, push image, image, documentation"]
[menu.main]
parent = "smn_images"
weight = 2
+++
<![end-metadata]-->
2014-05-21 21:05:19 +00:00
2015-06-08 03:07:20 +00:00
# Get started with Docker Hub
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
So far you've learned how to use the command line to run Docker on your local host.
You've learned how to [pull down images ](/userguide/usingdocker/ ) to build containers
from existing images and you've learned how to [create your own images ](/userguide/dockerimages ).
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
Next, you're going to learn how to use the [Docker Hub ](https://hub.docker.com ) to
simplify and enhance your Docker workflows.
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
The [Docker Hub ](https://hub.docker.com ) is a public registry maintained by Docker,
Inc. It contains over 15,000 images you can download and use to build containers. It also
provides authentication, work group structure, workflow tools like webhooks and build
triggers, and privacy tools like private repositories for storing images you don't want
to share publicly.
2014-05-21 21:05:19 +00:00
2014-06-01 20:48:04 +00:00
## Docker commands and Docker Hub
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
Docker itself provides access to Docker Hub services via the `docker search` ,
`pull` , `login` , and `push` commands. This page will show you how these commands work.
### Account creation and login
Typically, you'll want to start by creating an account on Docker Hub (if you haven't
2014-12-02 21:42:04 +00:00
already) and logging in. You can create your account directly on
2014-06-21 00:10:20 +00:00
[Docker Hub ](https://hub.docker.com/account/signup/ ), or by running:
2015-03-26 18:12:37 +00:00
$ docker login
2014-06-21 00:10:20 +00:00
2014-12-02 21:42:04 +00:00
This will prompt you for a user name, which will become the public namespace for your
2014-06-21 00:10:20 +00:00
public repositories.
If your user name is available, Docker will prompt you to enter a password and your
e-mail address. It will then automatically log you in. You can now commit and
push your own images up to your repos on Docker Hub.
> **Note:**
2015-07-10 18:49:57 +00:00
> Your authentication credentials will be stored in the `~/.docker/config.json`
2014-12-16 04:25:37 +00:00
> authentication file in your home directory.
2014-05-21 21:05:19 +00:00
## Searching for images
2014-06-21 00:52:30 +00:00
You can search the [Docker Hub ](https://hub.docker.com ) registry via its search
2014-06-21 00:10:20 +00:00
interface or by using the command line interface. Searching can find images by image
name, user name, or description:
2014-05-21 21:05:19 +00:00
2015-03-26 18:12:37 +00:00
$ docker search centos
2014-05-21 21:05:19 +00:00
NAME DESCRIPTION STARS OFFICIAL TRUSTED
centos Official CentOS 6 Image as of 12 April 2014 88
tianon/centos CentOS 5 and 6, created using rinse instea... 21
...
2015-04-22 03:36:27 +00:00
There you can see two example results: `centos` and `tianon/centos` . The second
result shows that it comes from the public repository of a user, named
`tianon/` , while the first result, `centos` , doesn't explicitly list a
repository which means that it comes from the trusted top-level namespace for
[Official Repositories ](/docker-hub/official_repos ). The `/` character separates
a user's repository from the image name.
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
Once you've found the image you want, you can download it with `docker pull <imagename>` :
2014-05-21 21:05:19 +00:00
2015-03-26 18:12:37 +00:00
$ docker pull centos
2014-05-21 21:05:19 +00:00
Pulling repository centos
0b443ba03958: Download complete
539c0211cd76: Download complete
511136ea3c5a: Download complete
7064731afe90: Download complete
2014-09-23 22:53:43 +00:00
Status: Downloaded newer image for centos
2014-06-21 00:10:20 +00:00
You now have an image from which you can run containers.
2014-05-21 21:05:19 +00:00
2014-06-01 20:48:04 +00:00
## Contributing to Docker Hub
2014-05-21 21:05:19 +00:00
2014-06-01 20:48:04 +00:00
Anyone can pull public images from the [Docker Hub ](https://hub.docker.com )
2014-05-21 21:05:19 +00:00
registry, but if you would like to share your own images, then you must
2015-08-06 23:00:49 +00:00
[register first ](/docker-hub/accounts ).
2014-05-21 21:05:19 +00:00
2014-06-01 20:48:04 +00:00
## Pushing a repository to Docker Hub
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
In order to push a repository to its registry, you need to have named an image
2014-05-21 21:05:19 +00:00
or committed your container to a named image as we saw
[here ](/userguide/dockerimages ).
2014-06-21 00:10:20 +00:00
Now you can push this repository to the registry designated by its name or tag.
2014-05-21 21:05:19 +00:00
2015-03-26 18:12:37 +00:00
$ docker push yourname/newimage
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
The image will then be uploaded and available for use by your team-mates and/or the
community.
2014-05-21 21:05:19 +00:00
2014-06-01 20:48:04 +00:00
## Features of Docker Hub
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
Let's take a closer look at some of the features of Docker Hub. You can find more
2015-06-10 06:13:11 +00:00
information [here ](https://docs.docker.com/docker-hub/ ).
2014-05-21 21:05:19 +00:00
* Private repositories
* Organizations and teams
* Automated Builds
* Webhooks
2015-04-21 15:50:09 +00:00
### Private repositories
2014-05-21 21:05:19 +00:00
Sometimes you have images you don't want to make public and share with
2014-06-01 20:48:04 +00:00
everyone. So Docker Hub allows you to have private repositories. You can
sign up for a plan [here ](https://registry.hub.docker.com/plans/ ).
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
### Organizations and teams
2014-05-21 21:05:19 +00:00
One of the useful aspects of private repositories is that you can share
2014-06-01 20:48:04 +00:00
them only with members of your organization or team. Docker Hub lets you
2014-05-21 21:05:19 +00:00
create organizations where you can collaborate with your colleagues and
2014-06-21 00:10:20 +00:00
manage private repositories. You can learn how to create and manage an organization
2014-06-01 20:48:04 +00:00
[here ](https://registry.hub.docker.com/account/organizations/ ).
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
### Automated Builds
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
Automated Builds automate the building and updating of images from
2015-06-13 16:21:50 +00:00
[GitHub ](https://www.github.com ) or [Bitbucket ](http://bitbucket.com ), directly on Docker
Hub. It works by adding a commit hook to your selected GitHub or Bitbucket repository,
2014-06-21 00:10:20 +00:00
triggering a build and update when you push a commit.
2014-05-21 21:05:19 +00:00
2014-06-21 00:10:20 +00:00
#### To setup an Automated Build
2014-05-21 21:05:19 +00:00
2014-06-01 20:48:04 +00:00
1. Create a [Docker Hub account ](https://hub.docker.com/ ) and login.
2015-06-13 16:21:50 +00:00
2. Link your GitHub or Bitbucket account through the ["Link Accounts" ](https://registry.hub.docker.com/account/accounts/ ) menu.
2014-09-10 19:08:05 +00:00
3. [Configure an Automated Build ](https://registry.hub.docker.com/builds/add/ ).
2015-06-13 16:21:50 +00:00
4. Pick a GitHub or Bitbucket project that has a `Dockerfile` that you want to build.
2014-05-21 21:05:19 +00:00
5. Pick the branch you want to build (the default is the `master` branch).
6. Give the Automated Build a name.
7. Assign an optional Docker tag to the Build.
8. Specify where the `Dockerfile` is located. The default is `/` .
Once the Automated Build is configured it will automatically trigger a
2014-06-21 00:10:20 +00:00
build and, in a few minutes, you should see your new Automated Build on the [Docker Hub ](https://hub.docker.com )
2015-06-13 16:21:50 +00:00
Registry. It will stay in sync with your GitHub and Bitbucket repository until you
2014-05-21 21:05:19 +00:00
deactivate the Automated Build.
2015-07-24 06:08:45 +00:00
To check the output and status of your Automated Build repositories, click on a repository name within the ["Your Repositories" page ](https://registry.hub.docker.com/repos/ ). Automated Builds are indicated by a check-mark icon next to the repository name. Within the repository details page, you may click on the "Build Details" tab to view the status and output of all builds triggered by the Docker Hub.
2014-05-21 21:05:19 +00:00
Once you've created an Automated Build you can deactivate or delete it. You
2014-06-21 00:10:20 +00:00
cannot, however, push to an Automated Build with the `docker push` command.
2015-06-13 16:21:50 +00:00
You can only manage it by committing code to your GitHub or Bitbucket
2014-05-21 21:05:19 +00:00
repository.
You can create multiple Automated Builds per repository and configure them
to point to specific `Dockerfile` 's or Git branches.
2015-04-21 15:50:09 +00:00
#### Build triggers
2014-05-21 21:05:19 +00:00
2014-06-01 20:48:04 +00:00
Automated Builds can also be triggered via a URL on Docker Hub. This
2014-05-21 21:05:19 +00:00
allows you to rebuild an Automated build image on demand.
2014-06-21 00:10:20 +00:00
### Webhooks
2014-05-21 21:05:19 +00:00
Webhooks are attached to your repositories and allow you to trigger an
event when an image or updated image is pushed to the repository. With
2014-06-21 00:10:20 +00:00
a webhook you can specify a target URL and a JSON payload that will be
2014-05-21 21:05:19 +00:00
delivered when the image is pushed.
2014-12-02 21:42:04 +00:00
See the Docker Hub documentation for [more information on
2015-06-10 06:13:11 +00:00
webhooks](https://docs.docker.com/docker-hub/repos/#webhooks)
2014-11-24 22:54:50 +00:00
2014-05-21 21:05:19 +00:00
## Next steps
Go and use Docker!