Fatskills
Practice. Master. Repeat.
Study Guide: Docker Docker Registry and Repository Image Naming Conventions registryusernamerepotag
Source: https://www.fatskills.com/kubernetes/chapter/docker-docker-registry-and-repository-image-naming-conventions-registryusernamerepotag

Docker Docker Registry and Repository Image Naming Conventions registryusernamerepotag

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~2 min read

1. Core Command / Concept

Docker image naming conventions help identify and manage unique images in a registry. Use the format registry/username/repo:tag for image names.

2. Step-by-Step

  1. Check the current Docker version: docker --version
  2. Create a new Docker repository: docker repository create myuser/myrepo
  3. Tag an existing image with a new name: docker tag myimage:latest myuser/myrepo:latest
  4. Push the new image to the registry: docker push myuser/myrepo:latest
  5. Pull the new image from the registry: docker pull myuser/myrepo:latest
  6. ⚠️ Delete all stopped containers: docker container prune
  7. Clean up unused images: docker image prune
  8. List all Docker images: docker images

3. Real Commands with Examples


Example 1: Create a new Docker repository

Purpose: Create a new Docker repository for storing images.
Command: docker repository create myuser/myrepo Flags: --name specifies the repository name.

Example 2: Tag an existing image

Purpose: Tag an existing image with a new name.
Command: docker tag myimage:latest myuser/myrepo:latest Flags: --tag specifies the new image name.

Example 3: Push an image to the registry

Purpose: Push an existing image to the Docker registry.
Command: docker push myuser/myrepo:latest Flags: --all-tags pushes all tags of the image.

4. Common Errors


Error 1: Image not found

Error message: Error: No such image: myimage:latest Why it happens: The image does not exist in the local Docker environment.
Fix: docker pull myimage:latest

Error 2: Repository not found

Error message: Error: repository not found: myuser/myrepo Why it happens: The repository does not exist in the Docker registry.
Fix: docker repository create myuser/myrepo

Error 3: Tag not found

Error message: Error: tag not found: myuser/myrepo:latest Why it happens: The tag does not exist in the repository.
Fix: docker tag myimage:latest myuser/myrepo:latest

5. Quick Checks


Scenario 1: Check if a repository exists

Situation: You want to check if a repository exists in the Docker registry.
Command: docker repository inspect myuser/myrepo Correct response: The repository details are displayed.

Scenario 2: Check if an image exists

Situation: You want to check if an image exists in the local Docker environment.
Command: docker images myimage:latest Correct response: The image details are displayed.

Scenario 3: Check if a tag exists

Situation: You want to check if a tag exists in the repository.
Command: docker tag myuser/myrepo:latest Correct response: The tag details are displayed.

6. Last-Minute Reference

• Docker registry URL: https://registry.hub.docker.com • Default Docker repository name: library • Default Docker username: your-username • Docker image name format: registry/username/repo:tag • ⚠️ Docker images are deleted with docker image prune • Docker images are listed with docker images • Docker repositories are created with docker repository create • Docker tags are created with docker tag • Docker images are pushed with docker push • Docker images are pulled with docker pull




ADVERTISEMENT