How to set the name and tag of the image being built?
The name and tag of a Docker image are set with the -t (or --tag) flag in the docker build command.
Syntax
bash
docker build -t NAME:TAG .Example
bash
docker build -t myapp:1.0 .Where:
| Part | Meaning |
|---|---|
myapp | image name |
1.0 | tag (version) |
. | build context (current directory) |
Details
-
If no tag is given, Docker assigns
latest:bashdocker build -t myapp .
→ this becomes myapp:latest
-
A tag can contain words, digits, environment names:
javascriptmyapp:dev myapp:prod myapp:v2
Summary
The name and tag are set with the
-tflag indocker build, in thename:tagformat.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.