2014-06-05 21:52:06 +00:00
|
|
|
page_title: Working with Docker.io
|
|
|
|
page_description: Learning how to use Docker.io to manage images and work flow
|
|
|
|
page_keywords: repo, Docker.io, Docker Hub, registry, index, repositories, usage, pull image, push image, image, documentation
|
2014-05-21 21:05:19 +00:00
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
# Working with Docker.io
|
2014-05-21 21:05:19 +00:00
|
|
|
|
|
|
|
So far we've seen a lot about how to use Docker on the command line and
|
|
|
|
your local host. We've seen [how to pull down
|
|
|
|
images](/userguide/usingdocker/) that you can run your containers from
|
|
|
|
and we've seen how to [create your own images](/userguide/dockerimages).
|
|
|
|
|
|
|
|
Now we're going to learn a bit more about
|
2014-06-05 21:52:06 +00:00
|
|
|
[Docker.io](https://index.docker.io) and how you can use it to enhance
|
2014-05-21 21:05:19 +00:00
|
|
|
your Docker work flows.
|
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
[Docker.io](https://index.docker.io) is the public registry that Docker
|
2014-05-21 21:05:19 +00:00
|
|
|
Inc maintains. It contains a huge collection of images, over 15,000,
|
|
|
|
that you can download and use to build your containers. It also provides
|
|
|
|
authentication, structure (you can setup teams and organizations), work
|
|
|
|
flow tools like webhooks and build triggers as well as privacy features
|
|
|
|
like private repositories for storing images you don't want to publicly
|
|
|
|
share.
|
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
## Docker commands and Docker.io
|
2014-05-21 21:05:19 +00:00
|
|
|
|
|
|
|
Docker acts as a client for these services via the `docker search`,
|
|
|
|
`pull`, `login` and `push` commands.
|
|
|
|
|
|
|
|
## Searching for images
|
|
|
|
|
|
|
|
As we've already seen we can search the
|
2014-06-05 21:52:06 +00:00
|
|
|
[Docker.io](https://index.docker.io) registry via it's search interface
|
2014-05-21 21:05:19 +00:00
|
|
|
or using the command line interface. Searching can find images by name,
|
|
|
|
user name or description:
|
|
|
|
|
|
|
|
$ sudo docker search centos
|
|
|
|
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
|
|
|
|
...
|
|
|
|
|
|
|
|
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, `tianon/`, while the first result,
|
|
|
|
`centos`, doesn't explicitly list a repository so it comes from the
|
|
|
|
trusted top-level namespace. The `/` character separates a user's
|
|
|
|
repository and the image name.
|
|
|
|
|
|
|
|
Once you have found the image you want, you can download it:
|
|
|
|
|
|
|
|
$ sudo docker pull centos
|
|
|
|
Pulling repository centos
|
|
|
|
0b443ba03958: Download complete
|
|
|
|
539c0211cd76: Download complete
|
|
|
|
511136ea3c5a: Download complete
|
|
|
|
7064731afe90: Download complete
|
|
|
|
|
|
|
|
The image is now available to run a container from.
|
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
## Contributing to Docker.io
|
2014-05-21 21:05:19 +00:00
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
Anyone can pull public images from the [Docker.io](http://index.docker.io)
|
2014-05-21 21:05:19 +00:00
|
|
|
registry, but if you would like to share your own images, then you must
|
|
|
|
register a user first as we saw in the [first section of the Docker User
|
2014-06-05 21:52:06 +00:00
|
|
|
Guide](/userguide/dockerio/).
|
2014-05-21 21:05:19 +00:00
|
|
|
|
|
|
|
To refresh your memory, you can create your user name and login to
|
2014-06-05 21:52:06 +00:00
|
|
|
[Docker.io](https://index.docker.io/account/signup/), or by running:
|
2014-05-21 21:05:19 +00:00
|
|
|
|
|
|
|
$ sudo docker login
|
|
|
|
|
|
|
|
This will prompt you for a user name, which will become a public
|
|
|
|
namespace for your public repositories, for example:
|
|
|
|
|
|
|
|
training/webapp
|
|
|
|
|
|
|
|
Here `training` is the user name and `webapp` is a repository owned by
|
|
|
|
that user.
|
|
|
|
|
|
|
|
If your user name is available then `docker` will also prompt you to
|
|
|
|
enter a password and your e-mail address. It will then automatically log
|
|
|
|
you in. Now you're ready to commit and push your own images!
|
|
|
|
|
|
|
|
> **Note:**
|
|
|
|
> Your authentication credentials will be stored in the [`.dockercfg`
|
|
|
|
> authentication file](#authentication-file) in your home directory.
|
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
## Pushing a repository to Docker.io
|
2014-05-21 21:05:19 +00:00
|
|
|
|
|
|
|
In order to push an repository to its registry you need to have named an image,
|
|
|
|
or committed your container to a named image as we saw
|
|
|
|
[here](/userguide/dockerimages).
|
|
|
|
|
|
|
|
Now you can push this repository to the registry designated by its name
|
|
|
|
or tag.
|
|
|
|
|
|
|
|
$ sudo docker push yourname/newimage
|
|
|
|
|
|
|
|
The image will then be uploaded and available for use.
|
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
## Features of Docker.io
|
2014-05-21 21:05:19 +00:00
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
Now let's look at some of the features of Docker.io. You can find more
|
2014-05-21 21:05:19 +00:00
|
|
|
information [here](/docker-io/).
|
|
|
|
|
|
|
|
* Private repositories
|
|
|
|
* Organizations and teams
|
|
|
|
* Automated Builds
|
|
|
|
* Webhooks
|
|
|
|
|
|
|
|
## Private Repositories
|
|
|
|
|
|
|
|
Sometimes you have images you don't want to make public and share with
|
2014-06-05 21:52:06 +00:00
|
|
|
everyone. So Docker.io allows you to have private repositories. You can
|
|
|
|
sign up for a plan [here](https://index.docker.io/plans/).
|
2014-05-21 21:05:19 +00:00
|
|
|
|
|
|
|
## Organizations and teams
|
|
|
|
|
|
|
|
One of the useful aspects of private repositories is that you can share
|
2014-06-05 21:52:06 +00:00
|
|
|
them only with members of your organization or team. Docker.io lets you
|
2014-05-21 21:05:19 +00:00
|
|
|
create organizations where you can collaborate with your colleagues and
|
|
|
|
manage private repositories. You can create and manage an organization
|
2014-06-05 21:52:06 +00:00
|
|
|
[here](https://index.docker.io/account/organizations/).
|
2014-05-21 21:05:19 +00:00
|
|
|
|
|
|
|
## Automated Builds
|
|
|
|
|
|
|
|
Automated Builds automate the building and updating of images from [GitHub](https://www.github.com)
|
2014-06-05 21:52:06 +00:00
|
|
|
or [BitBucket](http://bitbucket.com), directly on Docker.io. It works by adding a commit hook to
|
2014-05-21 21:05:19 +00:00
|
|
|
your selected GitHub or BitBucket repository, triggering a build and update when you push a
|
|
|
|
commit.
|
|
|
|
|
|
|
|
### To setup an Automated Build
|
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
1. Create a [Docker.io account](https://index.docker.io/) and login.
|
|
|
|
2. Link your GitHub or BitBucket account through the [`Link Accounts`](https://index.docker.io/account/accounts/) menu.
|
|
|
|
3. [Configure an Automated Build](https://index.docker.io/builds/).
|
2014-05-21 21:05:19 +00:00
|
|
|
4. Pick a GitHub or BitBucket project that has a `Dockerfile` that you want to build.
|
|
|
|
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
|
|
|
|
build, and in a few minutes, if there are no errors, you will see your
|
2014-06-05 21:52:06 +00:00
|
|
|
new Automated Build on the [Docker.io](https://index.docker.io) Registry.
|
2014-05-21 21:05:19 +00:00
|
|
|
It will stay in sync with your GitHub and BitBucket repository until you
|
|
|
|
deactivate the Automated Build.
|
|
|
|
|
|
|
|
If you want to see the status of your Automated Builds you can go to your
|
2014-06-05 21:52:06 +00:00
|
|
|
[Automated Builds page](https://index.docker.io/builds/) on the Docker.io,
|
2014-05-21 21:05:19 +00:00
|
|
|
and it will show you the status of your builds, and the build history.
|
|
|
|
|
|
|
|
Once you've created an Automated Build you can deactivate or delete it. You
|
|
|
|
cannot however push to an Automated Build with the `docker push` command.
|
|
|
|
You can only manage it by committing code to your GitHub or BitBucket
|
|
|
|
repository.
|
|
|
|
|
|
|
|
You can create multiple Automated Builds per repository and configure them
|
|
|
|
to point to specific `Dockerfile`'s or Git branches.
|
|
|
|
|
|
|
|
### Build Triggers
|
|
|
|
|
2014-06-05 21:52:06 +00:00
|
|
|
Automated Builds can also be triggered via a URL on Docker.io. This
|
2014-05-21 21:05:19 +00:00
|
|
|
allows you to rebuild an Automated build image on demand.
|
|
|
|
|
|
|
|
## Webhooks
|
|
|
|
|
|
|
|
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
|
|
|
|
a webhook you can specify a target URL and a JSON payload will be
|
|
|
|
delivered when the image is pushed.
|
|
|
|
|
|
|
|
## Next steps
|
|
|
|
|
|
|
|
Go and use Docker!
|
|
|
|
|