File: tag.md

package info (click to toggle)
docker.io 20.10.24%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 60,824 kB
  • sloc: sh: 5,621; makefile: 593; ansic: 179; python: 162; asm: 7
file content (75 lines) | stat: -rw-r--r-- 2,262 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
title: "tag"
description: "The tag command description and usage"
keywords: "tag, name, image"
---

# tag

```markdown
Usage:  docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

Options:
      --help   Print usage
```

## 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 `:8080`. If not present, the command
uses Docker's public registry located at `registry-1.docker.io` 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.

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.

You can group your images together using names and tags, and then upload them
to [*Share images on Docker Hub*](https://docs.docker.com/get-started/part3/).

## Examples

### Tag an image referenced by ID

To tag a local image with ID "0e5574283393" into the "fedora" repository with
"version1.0":

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

### Tag an image referenced by Name

To tag a local image with name "httpd" into the "fedora" repository with
"version1.0":

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

Note that since the tag name is not 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 name "httpd" and tag "test" into the "fedora"
repository with "version1.0.test":

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

### Tag an image for a private repository

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).

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