Bird
Raised Fist0
Dockerdevops~5 mins

Image naming conventions (registry/image:tag) in Docker - Commands & Configuration

Choose your learning style10 modes available
Introduction
When you use Docker images, you need a clear way to name them so you know what they are and where they come from. Image naming conventions help you organize and find images easily by using a format that includes the registry, image name, and tag.
When you want to pull a specific version of an image from a Docker registry.
When you build your own Docker image and want to give it a meaningful name and version.
When you push images to a private or public registry and need to avoid name conflicts.
When you want to run containers using images with clear version tags to avoid unexpected updates.
When you manage multiple images for different environments like development, testing, and production.
Commands
This command pulls the nginx image with the tag 1.23.3 from the default Docker Hub registry. The tag specifies the exact version you want.
Terminal
docker pull nginx:1.23.3
Expected OutputExpected
1.23.3: Pulling from library/nginx Digest: sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890 Status: Downloaded newer image for nginx:1.23.3 docker.io/library/nginx:1.23.3
This builds a Docker image from the current folder and tags it with a full name including a custom registry, image name, and version tag 2.0.
Terminal
docker build -t myregistry.example.com/myapp/backend:2.0 .
Expected OutputExpected
Sending build context to Docker daemon 10.24kB Step 1/5 : FROM python:3.10-slim ---> abcdef123456 Step 2/5 : COPY . /app ---> Using cache Step 3/5 : WORKDIR /app ---> Using cache Step 4/5 : RUN pip install -r requirements.txt ---> Using cache Step 5/5 : CMD ["python", "app.py"] ---> Using cache Successfully built abcdef123456 Successfully tagged myregistry.example.com/myapp/backend:2.0
→
-t - Assigns a name and optionally a tag in the 'name:tag' format to the image
This command uploads the image tagged as myregistry.example.com/myapp/backend:2.0 to the specified registry so others can use it.
Terminal
docker push myregistry.example.com/myapp/backend:2.0
Expected OutputExpected
The push refers to repository [myregistry.example.com/myapp/backend] 2.0: Pushed 2.0: digest: sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890 size: 1234
This runs a container using the image with the full name and tag, ensuring you use the exact version you want.
Terminal
docker run myregistry.example.com/myapp/backend:2.0
Expected OutputExpected
No output (command runs silently)
Key Concept

If you remember nothing else, remember: Docker image names follow the format registry/image:tag to clearly identify the source and version of the image.

Common Mistakes
Using image names without tags like 'nginx' expecting the latest version.
This pulls the 'latest' tag by default, which can change and cause unexpected behavior.
Always specify a tag like 'nginx:1.23.3' to use a fixed version.
Omitting the registry when pushing to a private registry.
Docker tries to push to Docker Hub by default and fails if the image name is not fully qualified.
Include the full registry URL in the image name, e.g., 'myregistry.example.com/myapp/backend:2.0'.
Using uppercase letters or invalid characters in image names.
Docker image names must be lowercase and can only contain certain characters; invalid names cause errors.
Use lowercase letters, digits, dashes, underscores, and dots only.
Summary
Docker image names use the format registry/image:tag to identify images clearly.
Tags specify the version or variant of the image to avoid surprises.
Always use full image names with registry and tag when building, pushing, or running images.

Practice

(1/5)
1. Which part of the Docker image name docker.io/library/nginx:latest specifies the version of the image?
easy
A. latest
B. docker.io
C. nginx
D. library

Solution

  1. Step 1: Identify the tag in the image name

    The tag is the part after the colon (:), which specifies the version or variant of the image.
  2. Step 2: Locate the tag in the example

    In docker.io/library/nginx:latest, the tag is latest.
  3. Final Answer:

    latest -> Option A
  4. Quick Check:

    Tag = latest [OK]
Hint: Tag is always after colon ':' in image name [OK]
Common Mistakes:
  • Confusing registry with tag
  • Thinking image name is the tag
  • Ignoring the colon separator
2. Which of the following is the correct syntax for a Docker image name with a registry, image, and tag?
easy
A. tag/image:registry
B. registry/image:tag
C. image:tag/registry
D. image/registry:tag

Solution

  1. Step 1: Recall the Docker image naming format

    The correct format is registry/image:tag, where registry is optional but comes first, then image name, then tag after colon.
  2. Step 2: Match the options to the format

    Only registry/image:tag matches the correct order and separators.
  3. Final Answer:

    registry/image:tag -> Option B
  4. Quick Check:

    Format = registry/image:tag [OK]
Hint: Registry first, then image, then tag after ':' [OK]
Common Mistakes:
  • Placing tag before image
  • Swapping registry and image order
  • Using wrong separators like '/' for tag
3. What is the full image name including registry and tag for the official Redis image version 7.0 from Docker Hub?
medium
A. docker.io/redis7:0
B. redis:7.0
C. redis/docker.io:7.0
D. docker.io/redis:7.0

Solution

  1. Step 1: Understand Docker Hub default registry

    Docker Hub's registry is docker.io. The official images are under this registry.
  2. Step 2: Compose full image name

    The full name includes registry, image name, and tag: docker.io/redis:7.0.
  3. Final Answer:

    docker.io/redis:7.0 -> Option D
  4. Quick Check:

    Full name = docker.io/redis:7.0 [OK]
Hint: Full name = registry/image:tag, Docker Hub registry is docker.io [OK]
Common Mistakes:
  • Putting registry after image
  • Missing registry for full name
  • Incorrect tag format
4. You try to pull the image myregistry.com/myapp but get an error. Which of these is a likely cause?
medium
A. Missing tag defaults to 'latest', but image may not have it
B. Registry name cannot contain dots '.'
C. Image name must always include a tag
D. Registry must be 'docker.io' only

Solution

  1. Step 1: Understand default tag behavior

    If no tag is given, Docker uses latest by default. If the image does not have a 'latest' tag, pull fails.
  2. Step 2: Check other options for errors

    Registry names can contain dots, tags are optional, and registries can be other than docker.io.
  3. Final Answer:

    Missing tag defaults to 'latest', but image may not have it -> Option A
  4. Quick Check:

    Default tag 'latest' may be missing [OK]
Hint: No tag means 'latest' assumed, may cause pull failure [OK]
Common Mistakes:
  • Thinking registry can't have dots
  • Believing tag is mandatory
  • Assuming only docker.io registry works
5. You want to tag a local image myapp to push it to a private registry at registry.example.com with version v2. Which command correctly tags the image?
hard
A. docker tag myapp:v2 registry.example.com/myapp
B. docker tag registry.example.com/myapp:v2 myapp
C. docker tag myapp registry.example.com/myapp:v2
D. docker tag myapp registry.example.com:v2/myapp

Solution

  1. Step 1: Understand docker tag syntax

    The syntax is docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG].
  2. Step 2: Apply to given names

    Source is myapp (local), target is registry.example.com/myapp:v2 to specify registry and tag.
  3. Final Answer:

    docker tag myapp registry.example.com/myapp:v2 -> Option C
  4. Quick Check:

    Tag command: source then target with registry and tag [OK]
Hint: Tag command: source image then target with registry:tag [OK]
Common Mistakes:
  • Swapping source and target images
  • Placing tag in wrong position
  • Using invalid registry/tag format
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard