Docker - Day -05
Demystifying Docker Image Names: A Guide to Pulling and Pushing with Confidence
Have you ever typed docker image pull httpd and wondered what's really happening behind the scenes? Docker image names, while seemingly simple, follow a specific convention that's crucial to understand. Grasping these conventions will save you from frustrating naming conflicts and ensure your images land in (and come from) the right places.
Let's break down the anatomy of a Docker image reference.
The Three Pillars of a Docker Image Name
A complete Docker image reference can have up to three distinct parts, each telling Docker where to find your image:
Registry: This is the hostname of the image registry where your images are stored. Think of it as the ultimate storage facility. Example docker.io
Namespace: This usually represents a user or organization that owns the image. It helps organize images within a registry. Example library
Repository: This is the actual name of the image project itself. Example nginx
The Defaults: Docker Hub and the "Library"
When you use a command like docker image pull httpd, Docker doesn't just guess where to find it. It makes some smart assumptions:
Implicit Namespace: If you only specify the repository name (like httpd), Docker assumes you're looking for an official image. Official images on Docker Hub live under the library namespace. So, httpd is effectively interpreted as library/httpd.
Default Registry: Docker's default registry is Docker Hub (docker.io). If you don't specify a registry hostname, Docker automatically looks there.
Putting it all together, docker image pull httpd is shorthand for pulling docker.io/library/httpd.

Beyond Docker Hub: Referencing Other Registries
Not all images live on Docker Hub. If you're working with images from other registries, such as Google Container Registry (GCR) or a private registry, you must explicitly include the registry's hostname in your image reference
# Google Container Registry (GCR)
gcr.io/your-project/httpd
# A private Azure Container registry
aksdevopsacrajay.azurecr.io/app1/app1nginx:9