This post will cover topic related to ‘Downloading Docker Images from a Registry’ with multiple docker command examples and different scenerios. So this will help you to understand the command docker and options available in it. Also this post will explain you how to use docker command.
The docker pull
command is used to download Docker images from a registry. Docker images are pre-built packages that contain all the components needed to run a containerized application.
Here are some examples demonstrating the usage of docker pull
:
Example 1: Pulling a specific version of an image from Docker Hub:
docker pull ubuntu:20.04
This command downloads the Ubuntu 20.04 image from Docker Hub.
Example 2: Pulling the latest version of an image:
docker pull nginx
This command fetches the latest nginx image from Docker Hub.
Example 3: Pulling an image with a specific tag:
docker pull node:14-alpine
Here, the command retrieves the Node.js 14 image based on Alpine Linux.
Example 4: Pulling an image from a private registry:
docker pull myregistry.example.com/myimage:latest
This example pulls an image named myimage
from a private Docker registry located at myregistry.example.com
.
Example 5: Pulling an image with authentication:
docker pull -u username -p password private.registry.com/image:tag
For private registries requiring authentication, you can specify the username and password with the -u
and -p
flags respectively.
Example 6: Pulling an image and specifying a specific architecture:
docker pull --platform linux/amd64 ubuntu:20.04
This command pulls the Ubuntu 20.04 image specifically for the AMD64 architecture.
Example 7: Pulling an image using a specific digest:
docker pull ubuntu@sha256:abcdef123456...
Here, the command retrieves the Ubuntu image using its unique digest, ensuring a specific immutable version.
Example 8: Pulling an image and saving it as a tarball:
docker pull nginx -o nginx.tar
This command pulls the nginx image and saves it as nginx.tar
in the current directory.
Example 9: Pulling an image with verbose output:
docker pull --verbose redis
Adding the --verbose
or -v
flag provides more detailed output during the image pull process.
Example 10: Pulling an image and checking its metadata:
docker pull --inspect ubuntu:20.04
This command pulls the Ubuntu 20.04 image and then inspects its metadata to verify details like the architecture and environment variables.
To verify whether the docker pull
command executed successfully, you can use:
docker images
This command lists all locally available Docker images. If the image you pulled appears in this list, it indicates that the pull operation was successful.
Also check similar articles.
Building Docker Images from a Dockerfile
Listing Docker Containers
Executing Commands Inside Docker Containers
How to Create and Run Docker Containers from an Image
How to Manage Kubernetes Plugins
Discussion about this post