Getting started overview

Getting started with Docker Hub involves a sequence of steps designed to enable users to manage container images. The initial process focuses on establishing an account, securing access credentials, and executing fundamental operations such as pulling and pushing images. Docker Hub integrates directly with the Docker command-line interface (CLI), which serves as the primary tool for interaction. Users can access public images without authentication, but interacting with private repositories or pushing any image requires login credentials.

The following table outlines the foundational steps for initiating work with Docker Hub:

Step What to Do Where
1. Create Docker ID Register for a free Docker account. Docker Hub registration page
2. Install Docker Desktop Download and install the Docker Desktop application, which includes the Docker Engine and CLI. Docker Desktop download page
3. Authenticate CLI Log in to Docker Hub via the command line. Your local terminal/command prompt: docker login
4. Pull Image Retrieve a public image from Docker Hub. Your local terminal/command prompt: docker pull hello-world
5. Push Image (Optional) Tag and upload an image to your Docker Hub repository. Your local terminal/command prompt: docker push yourusername/yourimage:tag

Create an account and get keys

To interact with Docker Hub beyond anonymous image pulls, a Docker ID is required. This ID grants access to features such as creating private repositories, pushing images, and configuring automated builds.

Account Creation

Navigate to the Docker Hub signup page. Provide a unique Docker ID, your email address, and a password. After completing the registration, a verification email will be sent to confirm your account. Account verification is a prerequisite for full functionality, including pushing images and managing repositories.

Authentication Methods

Docker Hub supports two primary methods for authentication when interacting with the Docker CLI:

  1. Username and Password: The most common method for initial setup. After installing Docker Desktop, open your terminal or command prompt and execute:

    docker login

    The CLI will prompt for your Docker ID and password. Upon successful authentication, a credential helper stores your login information, allowing subsequent Docker commands to operate without re-entering credentials. This helper is integrated with Docker Desktop installations and can be configured manually for other environments (e.g., Linux environments without Docker Desktop).

  2. Personal Access Tokens (PATs): For automated workflows, CI/CD pipelines, or increased security, Personal Access Tokens are recommended. PATs allow granular control over permissions and can be revoked independently of your main Docker Hub password. To generate a PAT:

    1. Log in to the Docker Hub website.
    2. Navigate to Account Settings > Security.
    3. Click New Access Token.
    4. Provide a descriptive name for the token and select the necessary permissions (e.g., Read & Write for pushing and pulling).
    5. Copy the generated token immediately, as it will not be displayed again.

    When using a PAT with docker login, enter your Docker ID as the username and the PAT as the password. For CI/CD systems, environment variables are typically used to securely store and inject PATs.

Your first request

Once authenticated, you can perform your first image pull from Docker Hub. This example uses the hello-world image, a small image designed to test Docker installations.

Pulling a Public Image

To download the hello-world image from Docker Hub, open your terminal and execute:

docker pull hello-world

The Docker CLI will connect to Docker Hub, retrieve the image layers, and store them locally. You should see output similar to:

Using default tag: latest
latest: Pulling from library/hello-world
... (download progress) ...
Digest: sha256:...(image digest)
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

To confirm the image is downloaded and run it, execute:

docker run hello-world

This command creates a container from the image, which prints a message to your console and then exits:

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

Pushing Your First Image (Optional)

To push an image to Docker Hub, you must first have an image built locally and tagged correctly. The tag must include your Docker ID as a prefix.

  1. Build an Image: Create a simple Dockerfile (e.g., Dockerfile in an empty directory):

    FROM alpine:latest
    CMD echo "Hello from my custom image!"

    Build the image, replacing yourusername with your Docker ID and my-first-image with your desired repository name:

    docker build -t yourusername/my-first-image:latest .
  2. Push the Image: Once built, push the image to your Docker Hub repository:

    docker push yourusername/my-first-image:latest

    Upon successful completion, the image will be available in your Docker Hub repositories. You can then pull this image from any machine where Docker is installed and authenticated to your account.

Common next steps

After successfully performing your first image operations, consider these common next steps to further integrate Docker Hub into your development workflow:

  • Explore Private Repositories: Create private repositories to store proprietary images that are not accessible to the public. This is crucial for commercial or internal projects. Learn more about managing Docker Hub repositories.

  • Automated Builds: Configure automated builds to connect your Docker Hub repositories to source code repositories (e.g., GitHub, Bitbucket). This automatically builds new images whenever changes are pushed to your source code, ensuring images are always up-to-date. Details are available in the Docker Hub automated builds documentation.

  • Webhooks: Set up webhooks to trigger actions in external systems when specific events occur in your Docker Hub repositories, such as a successful image push. This enables integration with CI/CD pipelines, notification services, or deployment tools. For example, a webhook could trigger a deployment on a Kubernetes cluster or send a Slack notification. The Docker Hub webhooks guide provides configuration instructions.

  • Team Collaboration: If working in a team, explore Docker Hub's team and organization features to manage access control, share repositories, and collaborate on image development. This includes setting up teams with specific permissions for different repositories. Refer to the Docker Hub organizations and teams documentation.

  • Integrate with CI/CD: Integrate Docker Hub into your Continuous Integration/Continuous Deployment (CI/CD) pipelines. Tools like AWS CodePipeline, GitHub Actions, or Google Cloud Build can be configured to build and push images to Docker Hub, then deploy them to various environments.

Troubleshooting the first call

Encountering issues during the initial setup is common. Here are solutions for frequent problems:

  • docker: command not found: This indicates that Docker Desktop or the Docker Engine is not installed or not correctly added to your system's PATH. Ensure Docker Desktop is running and that the Docker CLI is accessible from your terminal. Verify installation by running docker --version.

  • Error response from daemon: Get "https://registry-1.docker.io/v2/": unauthorized: authentication required: This error typically occurs when trying to push an image or access a private repository without being logged in to Docker Hub. Run docker login and provide your Docker ID and password (or PAT).

  • Error response from daemon: pull access denied for yourusername/yourimage, repository does not exist or may require 'docker login': This can happen if the repository name is incorrect, if you're trying to pull a private image without authentication, or if the image simply doesn't exist under that name. Double-check the image name and ensure you're logged in if it's a private repository.

  • Rate Limit Exceeded: For anonymous users, Docker Hub imposes a rate limit of 25 pulls per 6 hours. Authenticated users receive 100 pulls per 6 hours. If you exceed this, you'll receive an error message. Authenticating with docker login helps, and for higher limits, consider a paid Docker Hub subscription. You can use docker info | grep "Registry Hub" to check your current authentication status and potentially your remaining pulls.

  • denied: requested access to the resource is denied during push: This means your Docker ID is not correctly prefixed to the image tag, or you lack write permissions for the specified repository. Ensure your image is tagged as yourusername/repository-name:tag and that you are logged in with an account that has push access to that repository.

  • Incorrect Docker ID or Password: If docker login fails, verify your Docker ID and password. If you've forgotten your password, use the Docker Hub password reset feature. If using a PAT, ensure it hasn't expired or been revoked and that you copied the full token correctly.