Create an additional name reference for an existing image.
docker tag creates a new tag (a pointer) to an existing image ID. It copies nothing; the same image now answers to multiple names. This is how you prepare a locally built image for push to a registry namespace.
Usage
docker tag SOURCE[:TAG] TARGET[:TAG] - point TARGET at the SOURCE image
TARGET should include the registry host for non-Docker-Hub registries
No flags; both arguments are image references
Example
shell
docker build -t app:build .
docker tag app:build ghcr.io/myorg/app:${{ github.sha }}
docker tag app:build ghcr.io/myorg/app:latest
In CI
Build once with a local name, then tag the same image with each registry reference you intend to push (a SHA tag and latest). Because tags are just pointers, this is free and keeps the SHA and latest images byte-identical.
Key takeaways
docker tag adds a name; it does not copy or rebuild the image.
Include the registry host in the target tag for non-Docker-Hub registries.
Build once, tag many times, then push each reference.
Frequently asked questions
docker tag Command Reference?
docker tag creates a new tag (a pointer) to an existing image ID. It copies nothing; the same image now answers to multiple names. This is how you prepare a locally built image for push to a registry namespace.
In CI?
Build once with a local name, then tag the same image with each registry reference you intend to push (a SHA tag and latest). Because tags are just pointers, this is free and keeps the SHA and latest images byte-identical.