github.com/dpiddy/docker@v1.12.2-rc1/docs/getstarted/step_six.md (about)

     1  <!--[metadata]>
     2  +++
     3  aliases = [
     4  "/mac/step_six/",
     5  "/windows/step_six/",
     6  "/linux/step_six/",
     7  ]
     8  title = "Tag, push, & pull your image"
     9  description = "Getting started with Docker"
    10  keywords = ["beginner, getting started, Docker"]
    11  [menu.main]
    12  identifier = "getstart_tag_push_pull"
    13  parent = "tutorial_getstart_menu"
    14  weight = 6
    15  +++
    16  <![end-metadata]-->
    17  
    18  
    19  # Tag, push, and pull your image
    20  
    21  In this section, you tag and push your `docker-whale` image to your newly
    22  created repository. When you are done, you test the repository by pulling your
    23  new image.
    24  
    25  ## Step 1: Tag and push the image
    26  
    27  If you don't already have a terminal open, open one now:
    28  
    29  1. Go back to your command line terminal.
    30  
    31  2. At the prompt, type `docker images` to list the images you currently have:
    32  
    33          $ docker images
    34          REPOSITORY           TAG          IMAGE ID            CREATED             SIZE
    35          docker-whale         latest       7d9495d03763        38 minutes ago      273.7 MB
    36          <none>               <none>       5dac217f722c        45 minutes ago      273.7 MB
    37          docker/whalesay      latest       fb434121fc77        4 hours ago         247 MB
    38          hello-world          latest       91c95931e552        5 weeks ago         910 B
    39  
    40  5. Find the `IMAGE ID` for your `docker-whale` image.
    41  
    42    	 In this example, the id is `7d9495d03763`.
    43  
    44       Notice that currently, the `REPOSITORY` shows the repo name `docker-whale`
    45       but not the namespace. You need to include the `namespace` for Docker Hub to
    46       associate it with your account. The `namespace` is the same as your Docker
    47       Hub account name. You need to rename the image to
    48       `YOUR_DOCKERHUB_NAME/docker-whale`.
    49  
    50  6. Use `IMAGE ID` and the `docker tag` command to tag your `docker-whale` image.
    51  
    52      The command you type looks like this:
    53  
    54      ![Docker tag command](tutimg/tagger.png)
    55  
    56      Of course, your account name will be your own. So, you type the command with
    57      your image's ID and your account name and press RETURN.
    58  
    59  		$ docker tag 7d9495d03763 maryatdocker/docker-whale:latest
    60  
    61  7. Type the `docker images` command again to see your newly tagged image.
    62  
    63          $ docker images
    64          REPOSITORY                  TAG       IMAGE ID        CREATED          SIZE
    65          maryatdocker/docker-whale   latest    7d9495d03763    5 minutes ago    273.7 MB
    66          docker-whale                latest    7d9495d03763    2 hours ago      273.7 MB
    67          <none>                      <none>    5dac217f722c    5 hours ago      273.7 MB
    68          docker/whalesay             latest    fb434121fc77    5 hours ago      247 MB
    69          hello-world                 latest    91c95931e552    5 weeks ago      910 B
    70  
    71  8. Use the `docker login` command to log into the Docker Hub from the command line.
    72  
    73      The format for the login command is:
    74  
    75          docker login 
    76  
    77      When prompted, enter your password and press enter. So, for example:
    78  
    79          $ docker login
    80          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.
    81          Username: 
    82          Password:        
    83          Login Succeeded
    84  
    85  9. Type the `docker push` command to push your image to your new repository.
    86  
    87  		$ docker push maryatdocker/docker-whale
    88  			The push refers to a repository [maryatdocker/docker-whale] (len: 1)
    89  			7d9495d03763: Image already exists
    90  			c81071adeeb5: Image successfully pushed
    91  			eb06e47a01d2: Image successfully pushed
    92  			fb434121fc77: Image successfully pushed
    93  			5d5bd9951e26: Image successfully pushed
    94  			99da72cfe067: Image successfully pushed
    95  			1722f41ddcb5: Image successfully pushed
    96  			5b74edbcaa5b: Image successfully pushed
    97  			676c4a1897e6: Image successfully pushed
    98  			07f8e8c5e660: Image successfully pushed
    99  			37bea4ee0c81: Image successfully pushed
   100  			a82efea989f9: Image successfully pushed
   101  			e9e06b06e14c: Image successfully pushed
   102  			Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
   103  
   104  10. Return to your profile on Docker Hub to see your new image.
   105  
   106    ![Docker tag command](tutimg/new_image.png)
   107  
   108  ## Step 2: Pull your new image
   109  
   110  In this last section, you'll pull the image you just pushed to hub. Before you
   111  do that though, you'll need to remove the original image from your local
   112  machine. If you left the original image on your machine. Docker would not pull
   113  from the hub &mdash; why would it? The two images are identical.
   114  
   115  1. Make sure Docker is running, and open a command line terminal.
   116  
   117  2. At the prompt, type `docker images` to list the images you currently have on your local machine.
   118  
   119  		$ docker images
   120  		REPOSITORY                  TAG       IMAGE ID        CREATED          SIZE
   121  		maryatdocker/docker-whale   latest    7d9495d03763    5 minutes ago    273.7 MB
   122  		docker-whale                latest    7d9495d03763    2 hours ago      273.7 MB
   123  		<none>                      <none>    5dac217f722c    5 hours ago      273.7 MB
   124  		docker/whalesay             latest    fb434121fc77    5 hours ago      247 MB
   125  		hello-world                 latest    91c95931e552    5 weeks ago      910 B
   126  
   127      To make a good test, you need to remove the `maryatdocker/docker-whale` and
   128     `docker-whale` images from your local system. Removing them forces the next
   129     `docker pull` to get the image from your repository.
   130  
   131  3. Use the `docker rmi` to remove the `maryatdocker/docker-whale` and `docker-whale`
   132  images.
   133  
   134  	You can use an ID or the name to remove an image.
   135  
   136  		$ docker rmi -f 7d9495d03763
   137  		$ docker rmi -f docker-whale
   138  
   139  4. Pull and load a new image from your repository using the `docker run` command.
   140  
   141      The command you type should include your username from Docker Hub.
   142  
   143           docker run yourusername/docker-whale
   144  
   145  	Since the image is no longer available on your local system, Docker downloads it.
   146  
   147  		$ docker run maryatdocker/docker-whale
   148  		Unable to find image 'maryatdocker/docker-whale:latest' locally
   149  		latest: Pulling from maryatdocker/docker-whale
   150  		eb06e47a01d2: Pull complete
   151  		c81071adeeb5: Pull complete
   152  		7d9495d03763: Already exists
   153  		e9e06b06e14c: Already exists
   154  		a82efea989f9: Already exists
   155  		37bea4ee0c81: Already exists
   156  		07f8e8c5e660: Already exists
   157  		676c4a1897e6: Already exists
   158  		5b74edbcaa5b: Already exists
   159  		1722f41ddcb5: Already exists
   160  		99da72cfe067: Already exists
   161  		5d5bd9951e26: Already exists
   162  		fb434121fc77: Already exists
   163  		Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
   164  		Status: Downloaded newer image for maryatdocker/docker-whale:latest
   165           ________________________________________
   166          / Having wandered helplessly into a      \
   167          | blinding snowstorm Sam was greatly     |
   168          | relieved to see a sturdy Saint Bernard |
   169          | dog bounding toward him with the       |
   170          | traditional keg of brandy strapped to  |
   171          | his collar.                            |
   172          |                                        |
   173          | "At last," cried Sam, "man's best      |
   174          \ friend -- and a great big dog, too!"   /
   175           ----------------------------------------
   176                          \
   177                           \
   178                            \
   179                                    ##        .
   180                              ## ## ##       ==
   181                           ## ## ## ##      ===
   182                       /""""""""""""""""___/ ===
   183                  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
   184                       \______ o          __/
   185                        \    \        __/
   186                          \____\______/
   187  
   188  ## Where to go next
   189  
   190  You've done a lot, you've done all of the following fundamental Docker tasks.
   191  
   192  * installed Docker
   193  * run a software image in a container
   194  * located an interesting image on Docker Hub
   195  * run the image on your own machine
   196  * modified an image to create your own and run it
   197  * create a Docker Hub account and repository
   198  * pushed your image to Docker Hub for others to share
   199  
   200  <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>
   201  <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>
   202  
   203  You've only scratched the surface of what Docker can do. Go to the next page to [learn more](last_page.md).
   204  
   205  
   206  &nbsp;