0
0
DockerHow-ToBeginner · 3 min read

How to Pull Docker Image: Simple Guide with Examples

To pull a Docker image, use the docker pull <image-name> command. This downloads the image from a Docker registry like Docker Hub to your local machine so you can run containers from it.
📐

Syntax

The basic syntax to pull a Docker image is:

  • docker pull <image-name>[:<tag>]

Here:

  • <image-name> is the name of the image you want to download.
  • <tag> is optional and specifies the version of the image. If omitted, Docker pulls the latest tag by default.
bash
docker pull ubuntu:22.04
💻

Example

This example pulls the official Ubuntu image with the tag 22.04 from Docker Hub. It downloads the image layers to your local system so you can create containers based on Ubuntu 22.04.

bash
docker pull ubuntu:22.04
Output
22.04: Pulling from library/ubuntu Digest: sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Status: Downloaded newer image for ubuntu:22.04 docker.io/library/ubuntu:22.04
⚠️

Common Pitfalls

Some common mistakes when pulling Docker images include:

  • Forgetting to specify the tag and expecting a specific version, but Docker pulls latest by default.
  • Using an incorrect image name or misspelling it, which causes an error.
  • Not having internet access or Docker daemon running, which prevents pulling.

Always check the image name and tag carefully and ensure Docker is running.

bash
docker pull ubuntuu
# Error: repository does not exist

docker pull ubuntu:22.04
# Correct command pulls the image
📊

Quick Reference

CommandDescription
docker pull ubuntuPulls the latest Ubuntu image
docker pull nginx:1.23Pulls Nginx image version 1.23
docker pull myrepo/myimage:tagPulls image from a custom repository with tag
docker pull alpinePulls the latest Alpine Linux image

Key Takeaways

Use docker pull <image-name>[:<tag>] to download images from Docker Hub.
If no tag is specified, Docker pulls the latest version by default.
Check image names and tags carefully to avoid errors.
Ensure Docker daemon is running and you have internet access before pulling.
Use tags to get specific versions instead of relying on latest.