DEV Community

Victor Okonkwo
Victor Okonkwo

Posted on

Documentation: Pushing and Pulling a Docker Image to Docker Hub

This guide walks you through the steps to push a custom WordPress image to Docker Hub and verify it by pulling it back. It's designed to be beginner-friendly!


Step 1: Create a Docker Hub Account

  1. Sign Up for Docker Hub:
    • Go to the Docker Hub website.
    • Click on Sign Up.
    • Fill in the required details to create your account.

Docker Hub Sign Up


Step 2: Prepare Your Docker Image

  1. Tag the Image: To push an image to Docker Hub, it needs to be tagged correctly with the format:
   [DockerHubUsername]/[RepositoryName]:[Tag]
Enter fullscreen mode Exit fullscreen mode

Example:

   docker tag [IMAGE_ID] your-username/wordpress:latest
Enter fullscreen mode Exit fullscreen mode

In my case, I tagged my WordPress image:

   docker tag 2f3572d5cd72 your-username/wordpress:latest
Enter fullscreen mode Exit fullscreen mode
  • 2f3572d5cd72 is the image ID of my WordPress container.
  • your-username/wordpress:latest is the name and tag for the image in my Docker Hub repository.

Step 3: Push the Image to Docker Hub

  1. Login to Docker Hub: Before pushing an image, make sure you're logged in using:
   docker login
Enter fullscreen mode Exit fullscreen mode

Docker Login

  1. Push the Tagged Image: Use the docker push command to upload the image to Docker Hub:
   docker push your-username/wordpress:latest
Enter fullscreen mode Exit fullscreen mode
  • The output showed Docker uploading layers of my image to the repository. If some layers were already present in the official WordPress image, Docker reused them.
  1. Successful Push Confirmation: The output ended with:
   latest: digest: sha256:78a7f1bd075abad746e53aca7605976c2cf76796b1f868bc3adb17a98bbf0287 size: 5161
Enter fullscreen mode Exit fullscreen mode

This confirmed that the image was successfully pushed.


Step 4: Verify the Image on Docker Hub

  1. Check the Repository Online: I logged in to Docker Hub and navigated to my repository (your-username/wordpress). The image with the latest tag was listed there.

Docker Hub Repository


Step 5: Pull the Image to Verify

  1. Pull the Image: To test that the image works, I pulled it from Docker Hub using:
   docker pull your-username/wordpress:latest
Enter fullscreen mode Exit fullscreen mode
  • This downloaded the image from Docker Hub.
  • The successful pull confirmed that the image was stored correctly.

Tips & Notes

  • Login to Docker Hub: Before pushing an image, make sure you're logged in using:
  docker login
Enter fullscreen mode Exit fullscreen mode
  • Repository Naming: The name must include your Docker Hub username (e.g., your-username/wordpress).

That's it! Your WordPress image is now available on Docker Hub and ready for deployment anywhere.


Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay