summaryrefslogtreecommitdiff
path: root/devdocs/docker/engine%2Freference%2Fcommandline%2Ftag%2Findex.html
blob: 45d6247af77c8df6fd81b16f43a090768dbb3869 (plain)
1
2
3
4
5
6
7
8
9
10
11
<h1>docker tag</h1>  <p><br></p> <p>Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
</pre></div> <h2 id="description">Description</h2> <p name="extended-description">An image name is made up of slash-separated name components, optionally prefixed by a registry hostname. The hostname must comply with standard DNS rules, but may not contain underscores. If a hostname is present, it may optionally be followed by a port number in the format <code class="language-plaintext highlighter-rouge">:8080</code>. If not present, the command uses Docker’s public registry located at <code class="language-plaintext highlighter-rouge">registry-1.docker.io</code> by default. Name components may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.</p> <p>A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.</p> <p>You can group your images together using names and tags, and then upload them to <a href="../../../../get-started/04_sharing_app/index"><em>Share images on Docker Hub</em></a>.</p> <p>For example uses of this command, refer to the <a href="#examples">examples section</a> below.</p>  <h2 id="examples">Examples</h2> <h3 id="tag-an-image-referenced-by-id">Tag an image referenced by ID</h3> <p>To tag a local image with ID “0e5574283393” into the “fedora” repository with “version1.0”:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker tag 0e5574283393 fedora/httpd:version1.0
</pre></div> <h3 id="tag-an-image-referenced-by-name">Tag an image referenced by Name</h3> <p>To tag a local image with name “httpd” into the “fedora” repository with “version1.0”:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker tag httpd fedora/httpd:version1.0
</pre></div> <p>Note that since the tag name is not specified, the alias is created for an existing local version <code class="language-plaintext highlighter-rouge">httpd:latest</code>.</p> <h3 id="tag-an-image-referenced-by-name-and-tag">Tag an image referenced by Name and Tag</h3> <p>To tag a local image with name “httpd” and tag “test” into the “fedora” repository with “version1.0.test”:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker tag httpd:test fedora/httpd:version1.0.test
</pre></div> <h3 id="tag-an-image-for-a-private-repository">Tag an image for a private repository</h3> <p>To push an image to a private registry and not the central Docker registry you must tag it with the registry hostname and port (if needed).</p> <div class="highlight"><pre class="highlight" data-language="">$ docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0
</pre></div> <div class="_attribution">
  <p class="_attribution-p">
    &copy; 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
    <a href="https://docs.docker.com/engine/reference/commandline/tag/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/tag/</a>
  </p>
</div>