docker tag Command Reference
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:latestIn 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.
Related guides
docker push Command ReferenceReference for docker push in CI: publish a tagged image or all tags to a registry, with notes on authenticati…
docker build Command ReferenceReference for docker build in CI: tag, file, build-arg, target, platform, no-cache, and pull flags for buildi…
docker images Command ReferenceReference for docker images in CI: list local images with --filter, --format, and -q to inspect or script ove…