Skip to content

Commit

Permalink
Merge pull request docker#1655 from scjane/patch-1
Browse files Browse the repository at this point in the history
Update step_six.md
  • Loading branch information
Misty Stanley-Jones authored Feb 14, 2017
2 parents e7300cf + 7b05899 commit 96338d0
Showing 1 changed file with 122 additions and 119 deletions.
241 changes: 122 additions & 119 deletions engine/getstarted/step_six.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,147 +12,149 @@ redirect_from:
title: Tag, push, and pull your image
---

In this section, you tag and push your `docker-whale` image to your newly
created repository. When you are done, you test the repository by pulling your
In this section, you tag and push your `docker-whale` image to your new
repository, then test the repository by pulling your
new image.

## Step 1: Tag and push the image

If you don't already have a terminal open, open one now:
1. If you don't already have a terminal open, open one now.

1. Go back to your command line terminal.
2. Run `docker images` to list the images stored locally:

2. At the prompt, type `docker images` to list the images you currently have:
```bash
$ docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest 7d9495d03763 38 minutes ago 273.7 MB
<none> <none> 5dac217f722c 45 minutes ago 273.7 MB
docker/whalesay latest fb434121fc77 4 hours ago 247 MB
hello-world latest 91c95931e552 5 weeks ago 910 B
```

5. Find the image ID for the `docker-whale` image, in the second column. In this example,
the id is `7d9495d03763`, but yours will be different.

$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest 7d9495d03763 38 minutes ago 273.7 MB
<none> <none> 5dac217f722c 45 minutes ago 273.7 MB
docker/whalesay latest fb434121fc77 4 hours ago 247 MB
hello-world latest 91c95931e552 5 weeks ago 910 B
> **Note**: Currently, the repository shows the repo name `docker-whale`
> with no namespace. You need to include the `namespace` for Docker Hub to
> associate it with your account. The `namespace` is the same as your Docker
> Hub account name. The next step adds the namespace to the image name, like
>`YOUR_DOCKERHUB_NAME/docker-whale`.

5. Find the `IMAGE ID` for your `docker-whale` image.

In this example, the id is `7d9495d03763`.

Notice that currently, the `REPOSITORY` shows the repo name `docker-whale`
but not the namespace. You need to include the `namespace` for Docker Hub to
associate it with your account. The `namespace` is the same as your Docker
Hub account name. You need to rename the image to
`YOUR_DOCKERHUB_NAME/docker-whale`.

6. Use `IMAGE ID` and the `docker tag` command to tag your `docker-whale` image.
6. Tag the `docker-whale` image using the `docker tag` command and the image ID.

The command you type looks like this:

![Docker tag command](tutimg/tagger.png)

Of course, your account name will be your own. So, you type the command with
your image's ID and your account name and press RETURN.

$ docker tag 7d9495d03763 maryatdocker/docker-whale:latest

7. Type the `docker images` command again to see your newly tagged image.

$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
maryatdocker/docker-whale latest 7d9495d03763 5 minutes ago 273.7 MB
docker-whale latest 7d9495d03763 2 hours ago 273.7 MB
<none> <none> 5dac217f722c 5 hours ago 273.7 MB
docker/whalesay latest fb434121fc77 5 hours ago 247 MB
hello-world latest 91c95931e552 5 weeks ago 910 B

8. Use the `docker login` command to log into the Docker Hub from the command line.
Make sure to use your own Docker Hub account name.

```bash
$ docker tag 7d9495d03763 maryatdocker/docker-whale:latest
```

7. Run `docker images` again to verify that the `docker-whale` image has been tagged.

```bash
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
maryatdocker/docker-whale latest 7d9495d03763 5 minutes ago 273.7 MB
docker-whale latest 7d9495d03763 2 hours ago 273.7 MB
<none> <none> 5dac217f722c 5 hours ago 273.7 MB
docker/whalesay latest fb434121fc77 5 hours ago 247 MB
hello-world latest 91c95931e552 5 weeks ago 910 B
```

The same image ID actually now exists in two different repositories.

8. Before you can push the image to Docker Hub, you need to log in, using
the `docker login` command. The command doesn't take any parameters,
but prompts you for the username and password, as below:
```bash
$ docker login
Username: *****
Password: *****
Login Succeeded
```
The format for the login command is:
9. Push your tagged image to Docker Hub, using the `docker push` command. A
lot of output is generated, as each layer is pushed separately. That
output is truncated in the example below.
docker login
```bash
$ docker push maryatdocker/docker-whale
The push refers to a repository [maryatdocker/docker-whale] (len: 1)
7d9495d03763: Image already exists
...
e9e06b06e14c: Image successfully pushed
Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
```
When prompted, enter your password and press enter. So, for example:
10. Go back to the Docker Hub website to see the newly-pushed image.
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username:
Password:
Login Succeeded

9. Type the `docker push` command to push your image to your new repository.

$ docker push maryatdocker/docker-whale
The push refers to a repository [maryatdocker/docker-whale] (len: 1)
7d9495d03763: Image already exists
c81071adeeb5: Image successfully pushed
eb06e47a01d2: Image successfully pushed
fb434121fc77: Image successfully pushed
5d5bd9951e26: Image successfully pushed
99da72cfe067: Image successfully pushed
1722f41ddcb5: Image successfully pushed
5b74edbcaa5b: Image successfully pushed
676c4a1897e6: Image successfully pushed
07f8e8c5e660: Image successfully pushed
37bea4ee0c81: Image successfully pushed
a82efea989f9: Image successfully pushed
e9e06b06e14c: Image successfully pushed
Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011

10. Return to your profile on Docker Hub to see your new image.

![Docker tag command](tutimg/new_image.png)
![Docker tag command](tutimg/new_image.png)
## Step 2: Pull your new image
In this last section, you'll pull the image you just pushed to hub. Before you
do that though, you'll need to remove the original image from your local
machine. If you left the original image on your machine, Docker would not pull
from the hub &mdash; why would it? The two images are identical.
The goal of pushing the image to Docker Hub is so that you can access
it from any Docker host using `docker pull`. First, though, you need to
remove the local copy. Otherwise, `docker pull` will not have any work to do,
because it will see that you already have the latest version of the image
locally.
1. Make sure Docker is running, and open a command line terminal.
1. If you don't already have a terminal open, open one now.

2. At the prompt, type `docker images` to list the images you currently have on your local machine.
2. Use `docker images` to list the images you have locally.

```bash
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
maryatdocker/docker-whale latest 7d9495d03763 5 minutes ago 273.7 MB
docker-whale latest 7d9495d03763 2 hours ago 273.7 MB
<none> <none> 5dac217f722c 5 hours ago 273.7 MB
docker/whalesay latest fb434121fc77 5 hours ago 247 MB
hello-world latest 91c95931e552 5 weeks ago 910 B

To make a good test, you need to remove the `maryatdocker/docker-whale` and
`docker-whale` images from your local system. Removing them forces the next
`docker pull` to get the image from your repository.

3. Use the `docker rmi` to remove the `maryatdocker/docker-whale` and `docker-whale`
images.

You can use an ID or the name to remove an image.

$ docker rmi -f 7d9495d03763
$ docker rmi -f docker-whale

4. Pull and load a new image from your repository using the `docker run` command.

The command you type should include your username from Docker Hub.

docker run yourusername/docker-whale

Since the image is no longer available on your local system, Docker downloads it.

```

In the next step, you will remove both versions of the `docker-whale` image
from your local system. They share the same ID. Make a note of it.

3. Use the `docker image remove` command to remove the images. You can refer
to an image by its ID or its name. Since they share an ID, if you wanted to
keep one of them, you'd need to refer to the other one by name. For this
example, use the ID to remove both of them. Your ID will be different from
the one below.
```bash
$ docker image remove 7d9495d03763
```
4. When you use `docker run` it automatically downloads (pulls) images that
don't yet exist locally, creates a container, and starts it. Use the
following command to pull and run the `docker-whale` image, substituting
your Docker Hub username.

```bash
$ docker run yourusername/docker-whale
```

Since the image is no longer available on your local system, Docker
downloads it. The output below is truncated.

```bash
$ docker run maryatdocker/docker-whale
Unable to find image 'maryatdocker/docker-whale:latest' locally
latest: Pulling from maryatdocker/docker-whale
eb06e47a01d2: Pull complete
c81071adeeb5: Pull complete
7d9495d03763: Already exists
e9e06b06e14c: Already exists
a82efea989f9: Already exists
37bea4ee0c81: Already exists
07f8e8c5e660: Already exists
676c4a1897e6: Already exists
5b74edbcaa5b: Already exists
1722f41ddcb5: Already exists
99da72cfe067: Already exists
5d5bd9951e26: Already exists
...
fb434121fc77: Already exists
Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
Status: Downloaded newer image for maryatdocker/docker-whale:latest
Expand All @@ -178,23 +180,24 @@ images.
\______ o __/
\ \ __/
\____\______/
```

## Where to go next
## Next steps

You've done a lot, you've done all of the following fundamental Docker tasks.
After finishing this tutorial, you've done all of the following fundamental
Docker tasks.
* installed Docker
* run a software image in a container
* located an interesting image on Docker Hub
* run the image on your own machine
* modified an image to create your own and run it
* create a Docker Hub account and repository
* pushed your image to Docker Hub for others to share
* You installed Docker.
* You ran a software image in a container.
* You located an interesting image on Docker Hub and ran it on your own machine.
* You modified an image to create your own, and created and ran a container
based on that image.
* You created a Docker Hub account and repository.
* You pushed your custom image to Docker Hub, and made it available both for
yourself and other Docker users.
<a href="https://twitter.com/intent/tweet?button_hashtag=dockerdocs&text=Just%20ran%20a%20container%20with%20an%20image%20I%20built.%20Find%20it%20on%20%23dockerhub.%20Build%20your%20own%3A%20http%3A%2F%2Fgoo.gl%2FMUi7cA" class="twitter-hashtag-button" data-size="large" data-related="docker" target="_blank">Tweet your accomplishment!</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
You've only scratched the surface of what Docker can do. Go to the next page to [learn more](last_page.md).


&nbsp;
You've only scratched the surface of what Docker can do.
[Learn more](last_page.md) about where to go next.

0 comments on commit 96338d0

Please sign in to comment.