Skip to content
Fresh

docker image tag

Back

Reference

docker image tag

Copy as Markdown

Open MarkdownAsk Docs AIClaudeOpen in Claude

| Description | Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE | | Usage | docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] | | Aliases<br>An alias is a short or memorable alternative for a longer command. | docker tag |

Description

A Docker image reference consists of several components that describe where the image is stored and its identity. These components are:

text
[HOST[:PORT]/]NAMESPACE/REPOSITORY[:TAG]

HOSTSpecifies the registry location where the image resides. If omitted, Docker defaults to Docker Hub (docker.io).PORTAn optional port number for the registry, if necessary (for example, :5000).NAMESPACE/REPOSITORYThe namespace (optional) usually represents a user or organization. The repository is required and identifies the specific image. If the namespace is omitted, Docker defaults to library, the namespace reserved for Docker Official Images.TAGAn optional identifier used to specify a particular version or variant of the image. If no tag is provided, Docker defaults to latest.

Example image references

example.com:5000/team/my-app:2.0

  • Host: example.com
  • Port: 5000
  • Namespace: team
  • Repository: my-app
  • Tag: 2.0

alpine

  • Host: docker.io (default)
  • Namespace: library (default)
  • Repository: alpine
  • Tag: latest (default)

For more information on the structure and rules of image naming, refer to the Distribution reference as the canonical definition of the format.

Examples

Tag an image referenced by ID

To tag a local image with ID 0e5574283393 as fedora/httpd with the tag version1.0:

console
$ docker tag 0e5574283393 fedora/httpd:version1.0

Tag an image referenced by Name

To tag a local image httpd as fedora/httpd with the tag version1.0:

console
$ docker tag httpd fedora/httpd:version1.0

Note that since the tag name isn't specified, the alias is created for an existing local version httpd:latest.

Tag an image referenced by Name and Tag

To tag a local image with the name httpd and the tag test as fedora/httpd with the tag version1.0.test:

console
$ docker tag httpd:test fedora/httpd:version1.0.test

Tag an image for a private registry

To push an image to a private registry and not the public Docker registry you must include the registry hostname and port (if needed).

console
$ docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0