github.com/sld880311/docker@v0.0.0-20200524143708-d5593973a475/docs/reference/commandline/tag.md (about) 1 --- 2 title: "tag" 3 description: "The tag command description and usage" 4 keywords: "tag, name, image" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # tag 17 18 ```markdown 19 Usage: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] 20 21 Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE 22 23 Options: 24 --help Print usage 25 ``` 26 27 ## Description 28 29 An image name is made up of slash-separated name components, optionally prefixed 30 by a registry hostname. The hostname must comply with standard DNS rules, but 31 may not contain underscores. If a hostname is present, it may optionally be 32 followed by a port number in the format `:8080`. If not present, the command 33 uses Docker's public registry located at `registry-1.docker.io` by default. Name 34 components may contain lowercase letters, digits and separators. A separator 35 is defined as a period, one or two underscores, or one or more dashes. A name 36 component may not start or end with a separator. 37 38 A tag name must be valid ASCII and may contain lowercase and uppercase letters, 39 digits, underscores, periods and dashes. A tag name may not start with a 40 period or a dash and may contain a maximum of 128 characters. 41 42 You can group your images together using names and tags, and then upload them 43 to [*Share Images via Repositories*](https://docs.docker.com/engine/tutorials/dockerrepos/#/contributing-to-docker-hub). 44 45 ## Examples 46 47 ### Tag an image referenced by ID 48 49 To tag a local image with ID "0e5574283393" into the "fedora" repository with 50 "version1.0": 51 52 ```bash 53 $ docker tag 0e5574283393 fedora/httpd:version1.0 54 ``` 55 56 ### Tag an image referenced by Name 57 58 To tag a local image with name "httpd" into the "fedora" repository with 59 "version1.0": 60 61 ```bash 62 $ docker tag httpd fedora/httpd:version1.0 63 ``` 64 65 Note that since the tag name is not specified, the alias is created for an 66 existing local version `httpd:latest`. 67 68 ### Tag an image referenced by Name and Tag 69 70 To tag a local image with name "httpd" and tag "test" into the "fedora" 71 repository with "version1.0.test": 72 73 ```bash 74 $ docker tag httpd:test fedora/httpd:version1.0.test 75 ``` 76 77 ### Tag an image for a private repository 78 79 To push an image to a private registry and not the central Docker 80 registry you must tag it with the registry hostname and port (if needed). 81 82 ```bash 83 $ docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0 84 ```