github.com/portworx/docker@v1.12.1/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             VIRTUAL 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          VIRTUAL 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 --username=yourhubusername --email=youremail@company.com
    76  
    77      When prompted, enter your password and press enter. So, for example:
    78  
    79          $ docker login --username=maryatdocker --email=mary@docker.com
    80          Password:
    81          WARNING: login credentials saved in C:\Users\sven\.docker\config.json
    82          Login Succeeded
    83  
    84  9. Type the `docker push` command to push your image to your new repository.
    85  
    86  		$ docker push maryatdocker/docker-whale
    87  			The push refers to a repository [maryatdocker/docker-whale] (len: 1)
    88  			7d9495d03763: Image already exists
    89  			c81071adeeb5: Image successfully pushed
    90  			eb06e47a01d2: Image successfully pushed
    91  			fb434121fc77: Image successfully pushed
    92  			5d5bd9951e26: Image successfully pushed
    93  			99da72cfe067: Image successfully pushed
    94  			1722f41ddcb5: Image successfully pushed
    95  			5b74edbcaa5b: Image successfully pushed
    96  			676c4a1897e6: Image successfully pushed
    97  			07f8e8c5e660: Image successfully pushed
    98  			37bea4ee0c81: Image successfully pushed
    99  			a82efea989f9: Image successfully pushed
   100  			e9e06b06e14c: Image successfully pushed
   101  			Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
   102  
   103  10. Return to your profile on Docker Hub to see your new image.
   104  
   105    ![Docker tag command](tutimg/new_image.png)
   106  
   107  ## Step 2: Pull your new image
   108  
   109  In this last section, you'll pull the image you just pushed to hub. Before you
   110  do that though, you'll need to remove the original image from your local
   111  machine. If you left the original image on your machine. Docker would not pull
   112  from the hub &mdash; why would it? The two images are identical.
   113  
   114  1. Make sure Docker is running, and open a command line terminal.
   115  
   116  2. At the prompt, type `docker images` to list the images you currently have on your local machine.
   117  
   118  		$ docker images
   119  		REPOSITORY                  TAG       IMAGE ID        CREATED          VIRTUAL SIZE
   120  		maryatdocker/docker-whale   latest    7d9495d03763    5 minutes ago    273.7 MB
   121  		docker-whale                latest    7d9495d03763    2 hours ago      273.7 MB
   122  		<none>                      <none>    5dac217f722c    5 hours ago      273.7 MB
   123  		docker/whalesay             latest    fb434121fc77    5 hours ago      247 MB
   124  		hello-world                 latest    91c95931e552    5 weeks ago      910 B
   125  
   126      To make a good test, you need to remove the `maryatdocker/docker-whale` and
   127     `docker-whale` images from your local system. Removing them forces the next
   128     `docker pull` to get the image from your repository.
   129  
   130  3. Use the `docker rmi` to remove the `maryatdocker/docker-whale` and `docker-whale`
   131  images.
   132  
   133  	You can use an ID or the name to remove an image.
   134  
   135  		$ docker rmi -f 7d9495d03763
   136  		$ docker rmi -f docker-whale
   137  
   138  4. Pull and load a new image from your repository using the `docker run` command.
   139  
   140      The command you type should include your username from Docker Hub.
   141  
   142           docker run yourusername/docker-whale
   143  
   144  	Since the image is no longer available on your local system, Docker downloads it.
   145  
   146  		$ docker run maryatdocker/docker-whale
   147  		Unable to find image 'maryatdocker/docker-whale:latest' locally
   148  		latest: Pulling from maryatdocker/docker-whale
   149  		eb06e47a01d2: Pull complete
   150  		c81071adeeb5: Pull complete
   151  		7d9495d03763: Already exists
   152  		e9e06b06e14c: Already exists
   153  		a82efea989f9: Already exists
   154  		37bea4ee0c81: Already exists
   155  		07f8e8c5e660: Already exists
   156  		676c4a1897e6: Already exists
   157  		5b74edbcaa5b: Already exists
   158  		1722f41ddcb5: Already exists
   159  		99da72cfe067: Already exists
   160  		5d5bd9951e26: Already exists
   161  		fb434121fc77: Already exists
   162  		Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
   163  		Status: Downloaded newer image for maryatdocker/docker-whale:latest
   164           ________________________________________
   165          / Having wandered helplessly into a      \
   166          | blinding snowstorm Sam was greatly     |
   167          | relieved to see a sturdy Saint Bernard |
   168          | dog bounding toward him with the       |
   169          | traditional keg of brandy strapped to  |
   170          | his collar.                            |
   171          |                                        |
   172          | "At last," cried Sam, "man's best      |
   173          \ friend -- and a great big dog, too!"   /
   174           ----------------------------------------
   175                          \
   176                           \
   177                            \
   178                                    ##        .
   179                              ## ## ##       ==
   180                           ## ## ## ##      ===
   181                       /""""""""""""""""___/ ===
   182                  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
   183                       \______ o          __/
   184                        \    \        __/
   185                          \____\______/
   186  
   187  ## Where to go next
   188  
   189  You've done a lot, you've done all of the following fundamental Docker tasks.
   190  
   191  * installed Docker
   192  * run a software image in a container
   193  * located an interesting image on Docker Hub
   194  * run the image on your own machine
   195  * modified an image to create your own and run it
   196  * create a Docker Hub account and repository
   197  * pushed your image to Docker Hub for others to share
   198  
   199  <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>
   200  <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>
   201  
   202  You've only scratched the surface of what Docker can do. Go to the next page to [learn more](last_page.md).
   203  
   204  
   205  &nbsp;