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
-
Sign Up for Docker Hub:
- Go to the Docker Hub website.
- Click on Sign Up.
- Fill in the required details to create your account.
Step 2: Prepare Your Docker Image
- Tag the Image: To push an image to Docker Hub, it needs to be tagged correctly with the format:
[DockerHubUsername]/[RepositoryName]:[Tag]
Example:
docker tag [IMAGE_ID] your-username/wordpress:latest
In my case, I tagged my WordPress image:
docker tag 2f3572d5cd72 your-username/wordpress:latest
-
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
- Login to Docker Hub: Before pushing an image, make sure you're logged in using:
docker login
-
Push the Tagged Image:
Use the
docker push
command to upload the image to Docker Hub:
docker push your-username/wordpress:latest
- 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.
- Successful Push Confirmation: The output ended with:
latest: digest: sha256:78a7f1bd075abad746e53aca7605976c2cf76796b1f868bc3adb17a98bbf0287 size: 5161
This confirmed that the image was successfully pushed.
Step 4: Verify the Image on Docker Hub
-
Check the Repository Online:
I logged in to Docker Hub and navigated to my repository (
your-username/wordpress
). The image with thelatest
tag was listed there.
Step 5: Pull the Image to Verify
- Pull the Image: To test that the image works, I pulled it from Docker Hub using:
docker pull your-username/wordpress:latest
- 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
-
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)