Sub topic 7
Checking the Result on Docker Hub and by Pulling
This chapter assumes you have Docker installed, a Docker Hub account, and a local image already tagged as YOUR_USERNAME/myapp:1.0 and pushed with docker push. A push that prints no error is a good sign, but it is not proof. This chapter shows two independent ways to confirm that the image reached Docker Hub and that other machines can use it.
Check the repository on Docker Hub
Open https://hub.docker.com and sign in. Go to Repositories and select YOUR_USERNAME/myapp. Check these items:
- Tags tab: the tag
1.0is listed, with a recent "last pushed" time. - Digest: each tag shows a digest, a
sha256:value that identifies the exact image contents. - OS/Arch: the platform, such as
linux/amd64, matches the machine you built on. - Visibility: the repository shows as Public or Private, as you intended.
If the tag is missing, the push went to a different repository or tag than you expected. Compare the name in the web page with the name you typed in docker push.
Check by pulling the image back
The web page shows that Docker Hub stored something. A pull shows that the stored image downloads and runs. This is the stronger test.
Docker will not download an image it already has locally, so the pull would prove nothing if the local copy were still present. Remove the local tag first:
docker rmi YOUR_USERNAME/myapp:1.0
docker pull YOUR_USERNAME/myapp:1.0
docker run --rm YOUR_USERNAME/myapp:1.0Expected output from the final command:
Hello from Docker HubThe --rm flag deletes the container when it exits, so no stopped containers pile up.
Note that docker rmi removes only the tag you name. If the original tag myapp:1.0 still points to the same image, Docker removes just the extra name and keeps the image data. In that case the pull may report that the image is already up to date, because the layers are still on disk. For a strict test, also remove the other tag, or run the pull on a different machine.
1.0: Pulling from YOUR_USERNAME/myapp
Digest: sha256:...
Status: Image is up to date for YOUR_USERNAME/myapp:1.0Compare digests
A digest is the reliable way to confirm that two images are identical. A tag can be moved to a different image, but a digest cannot change without changing the content. After a push, Docker prints a line like this:
1.0: digest: sha256:3f1c...e9a2 size: 528After a pull, the output contains a Digest: line. If both values match, the image you pulled is the image you pushed. You can also list local digests:
docker images --digests YOUR_USERNAME/myappTo pull by digest instead of by tag, use @:
docker pull YOUR_USERNAME/myapp@sha256:YOUR_DIGESTHow the check flows
Common mistakes when verifying
| Symptom | Likely cause | Fix |
|---|---|---|
| Tag not shown on Docker Hub | Pushed under a different name or tag | Run `docker images` and compare names with the web page |
| Pull says "up to date" immediately | Local copy still exists | Remove all local tags of the image, then pull again |
| `pull access denied` or `repository does not exist` | Typo in the name, or a private repository you are not logged in to | Check spelling, then run `docker login` |
| Wrong digest after pull | A different image was pushed to the same tag | Re-push, and prefer unique tags such as version numbers |
Exercise
You run docker rmi YOUR_USERNAME/myapp:1.0 and then docker pull YOUR_USERNAME/myapp:1.0. Docker reports "Image is up to date" without downloading anything. The original tag myapp:1.0 still exists locally. Does this prove the push worked? Why or why not?
Show answer
No. docker rmi removed only the extra tag, and myapp:1.0 still points to the same image data on disk. Docker found the layers locally, so it did not need to download anything. To test the push properly, remove every local tag of the image, or pull from a different machine, and then compare the pulled digest with the one printed by docker push.