github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/image_tag.md (about) 1 # tag 2 3 <!---MARKER_GEN_START--> 4 Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE 5 6 ### Aliases 7 8 `docker image tag`, `docker tag` 9 10 11 <!---MARKER_GEN_END--> 12 13 ## Description 14 15 A full image name has the following format and components: 16 17 `[HOST[:PORT_NUMBER]/]PATH` 18 19 - `HOST`: The optional registry hostname specifies where the image is located. 20 The hostname must comply with standard DNS rules, but may not contain 21 underscores. If you don't specify a hostname, the command uses Docker's public 22 registry at `registry-1.docker.io` by default. Note that `docker.io` is the 23 canonical reference for Docker's public registry. 24 - `PORT_NUMBER`: If a hostname is present, it may optionally be followed by a 25 registry port number in the format `:8080`. 26 - `PATH`: The path consists of slash-separated components. Each 27 component may contain lowercase letters, digits and separators. A separator is 28 defined as a period, one or two underscores, or one or more hyphens. A component 29 may not start or end with a separator. While the 30 [OCI Distribution Specification](https://github.com/opencontainers/distribution-spec) 31 supports more than two slash-separated components, most registries only support 32 two slash-separated components. For Docker's public registry, the path format is 33 as follows: 34 - `[NAMESPACE/]REPOSITORY`: The first, optional component is typically a 35 user's or an organization's namespace. The second, mandatory component is the 36 repository name. When the namespace is not present, Docker uses `library` 37 as the default namespace. 38 39 After the image name, the optional `TAG` is a custom, human-readable manifest 40 identifier that's typically a specific version or variant of an image. The tag 41 must be valid ASCII and can contain lowercase and uppercase letters, digits, 42 underscores, periods, and hyphens. It can't start with a period or hyphen and 43 must be no longer than 128 characters. If you don't specify a tag, the command uses `latest` by default. 44 45 You can group your images together using names and tags, and then 46 [push](image_push.md) them to a registry. 47 48 ## Examples 49 50 ### Tag an image referenced by ID 51 52 To tag a local image with ID `0e5574283393` as `fedora/httpd` with the tag 53 `version1.0`: 54 55 ```console 56 $ docker tag 0e5574283393 fedora/httpd:version1.0 57 ``` 58 59 ### Tag an image referenced by Name 60 61 To tag a local image `httpd` as `fedora/httpd` with the tag `version1.0`: 62 63 ```console 64 $ docker tag httpd fedora/httpd:version1.0 65 ``` 66 67 Note that since the tag name isn't specified, the alias is created for an 68 existing local version `httpd:latest`. 69 70 ### Tag an image referenced by Name and Tag 71 72 To tag a local image with the name `httpd` and the tag `test` as `fedora/httpd` 73 with the tag `version1.0.test`: 74 75 ```console 76 $ docker tag httpd:test fedora/httpd:version1.0.test 77 ``` 78 79 ### Tag an image for a private registry 80 81 To push an image to a private registry and not the public Docker registry you 82 must include the registry hostname and port (if needed). 83 84 ```console 85 $ docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0 86 ```