Examining image repository names

Repositories have a fixed naming scheme: {registry-domain}/{account-id}/{repository-name}:{tag}. All parts are required, but Docker assumes defaults for some values. So dockeronwindows/ch02-powershell-env:2e is actually a short form of the full repository name, docker.io/dockeronwindows/ch02-powershell-env:2e:

  • registry-domain is the domain name or IP address of the registry that stores the image. Docker Hub is the default registry, so you can omit the registry domain when you're using images from Hub. Docker will use docker.io as the registry if you don't specify one.
  • account-id is the name of the account or organization which owns the image on the registry. On Docker Hub the account name is mandatory. My own account ID is sixeyed, and the organization account ID for the images that accompany this book is dockeronwindows. On other registries, the account ID may not be needed.
  • repository-name is the name you want to give your image to uniquely identify the application, within all the repositories for your account on the registry.
  • tag is how you distinguish between different image variations in the repository.

You use the tag for versioning your applications or to identify variants. If you don't specify a tag when you build or pull images, Docker uses the default tag  latest. When you start with Docker you will use Docker Hub and the latest tag, which are the defaults that Docker provides to hide some of the complexity until you're ready to dig deeper. As you continue with Docker, you'll use tags to make clear distinctions between different versions of your application package.

A good example of this is Microsoft's .NET Core base image, which is on Docker Hub in the microsoft/dotnet repository. .NET Core is a cross-platform application stack which runs on Linux and Windows. You can only run Linux containers on Linux-based Docker hosts, and you can only run Windows containers on Windows-based Docker hosts, so Microsoft includes the operating system in the tag name.

At the time of writing, Microsoft has dozens of versions of the .NET Core image available for use in the microsoft/dotnet repository, identified with different tags. These are just some of the tags:

  • 2.2-runtime-bionic a Linux image based on Ubuntu version 18.04 which has the .NET Core 2.2 runtime installed
  • 2.2-runtime-nanoserver-1809 a Nano Server version 1809 image which has the .NET Core 2.2 runtime installed
  • 2.2-sdk-bionic a Linux image based on Debian which has the .NET Core 2.2 runtime and SDK installed
  • 2.2-sdk-nanoserver-1809 a Nano Server image which has the .NET Core 2.2 runtime and SDK installed

The tags make it clear what each image contains, but they are all fundamentally similar they are all variations of microsoft/dotnet.

Docker also supports multi-arch images, where a single image tag is used as an umbrella for many variations. There could be image variations based on Linux and Windows OS, or Intel and Advanced RISC Machines (ARM) processors. They all use the same image name, and when you run docker image pull, Docker pulls the matching image for your host's operating system and CPU architecture. .NET Core images do this – docker image pull microsoft/dotnet:2.2-sdk will download the Linux image on Linux machines, and the Windows image on Windows machines.

If you publish a cross-platform app to Docker Hub and you want to make it as easy as possible for consumers to use it, you should publish it as a multi-arch image. In your own development, it's better to be explicit and specify the exact FROM image in your Dockerfiles, otherwise your app will build differently on different operating systems.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.172.115