Skip to main content
In this guide, you’ll learn how to:
  • Pull images from public and private registries
  • Authenticate with docker login
  • Retag (rename) images
  • Push images to private registries
  • Inspect actual disk usage with Docker

1. Pulling Images from a Public Registry

Pulling from a public registry (for example, the official Ubuntu image on Docker Hub) requires no authentication:
By default, docker pull ubuntu retrieves the latest tag. To pull a specific version, append the tag (e.g., ubuntu:20.04).

2. Accessing Private Repositories

Attempting to pull an image from a private registry without logging in will result in an access denied error:
Similarly, pushing without authentication will fail:
You must authenticate before pulling from or pushing to private registries.
Make sure your credentials have the necessary permissions.

3. Logging In to a Registry

Use docker login to authenticate. By default, it targets Docker Hub (docker.io).
Example:
For other registries such as Google Container Registry:
Once logged in, subsequent docker pull and docker push commands will use your credentials.

4. Retagging (Renaming) an Image

Docker images cannot be renamed directly. Instead, you can create a new tag—a “soft link” to the same image ID.
  1. List local images:
  2. Retag httpd:alpine to httpd:customv1:
  3. Confirm the new tag:
Example output:
Notice httpd:alpine and httpd:customv1 share the same IMAGE ID—no duplicate layers are created.

5. Pushing to a Private Registry

To push your retagged image:
Make sure you are logged in (docker login gcr.io) before pushing.

6. Checking Actual Disk Usage

Use docker system df to inspect disk usage across images, containers, volumes, and build cache:
Example:
Even if docker image ls lists four tags, docker system df shows only three unique images. The SIZE column reflects unique layers, and RECLAIMABLE indicates potential space savings.

Command Reference Table


Watch Video