Sub topic 7
Checking the result on Docker Hub and by pulling
A push that finishes without an error is a good sign, but it is not proof. This chapter shows how to confirm that your image is on Docker Hub, that the tag points where you expect, and that someone else can download and run it.
This chapter assumes you have already built myapp:1.0, logged in with docker login, and run docker push YOUR_USERNAME/myapp:1.0. You should know what a tag and a repository are. Everything here uses the example from the earlier chapters.
What a successful push tells you
At the end of a push, Docker prints a line like this:
1.0: digest: sha256:3f1c0a9e5b7d4c2a8e6f1b0d9c7a5e3f2b4d6a8c0e1f3a5b7c9d1e3f5a7b9c1d size: 527Three pieces of information are in that line:
1.0is the tag that was created or updated in the repository.sha256:...is the digest of the image manifest. The manifest is a small JSON document that lists the image's configuration and its layers. The digest is a fingerprint of that document. Two images with the same digest are the same image.sizeis the size of the manifest in bytes. It is not the size of the image.
Keep the digest. It is the most precise way to identify what you pushed, and you will compare it against other views of the image below.
Three ways to verify
Each check answers a different question, and each costs a different amount.
| Check | Question it answers | Downloads layers? |
|---|---|---|
| Docker Hub web page | Is the tag listed, and when was it pushed? | No |
| Registry query (`imagetools inspect`, `manifest inspect`) | Does the registry hold a manifest for this tag, and which platforms does it cover? | No |
| `docker pull` and `docker run` | Can a client fetch every layer and start a container? | Yes, for layers it lacks |
The pull is the strongest test, because it exercises the same path every user of your image will take.
Check the repository page
Sign in at hub.docker.com and open the repository YOUR_USERNAME/myapp. Look at these places:
- General tab. It shows the repository name, its visibility (public or private), and when it was last pushed.
- Tags tab. It lists each tag with its operating system and architecture, the compressed size, and the time of the last push. Your
1.0tag should be there. - Tag detail page. Select the tag to see its digest and the layers. The digest should match the one printed by
docker push.
If the page shows no tags after a push that reported success, you are probably looking at the wrong repository or the wrong account. Check the namespace in the URL.
You can also read the same data from the Docker Hub API. For a public repository, no login is needed:
curl -s "https://hub.docker.com/v2/repositories/YOUR_USERNAME/myapp/tags/1.0"The response is JSON. Look for the name, digest, and last_updated fields. Private repositories return a "not found" style error to anonymous requests, which is expected.
Query the registry without downloading
Two commands read the manifest straight from the registry. Neither stores layers on your machine.
docker buildx imagetools inspect YOUR_USERNAME/myapp:1.0The output starts with the name, the media type, and the digest, then lists the manifest. For a single-platform image it shows one platform. For a multi-platform image, covered in a later chapter, it lists one entry per platform.
docker manifest inspect YOUR_USERNAME/myapp:1.0This prints the raw manifest JSON, including each layer's digest and size. It is useful when you need to see exactly what the registry holds. On some Docker versions it is marked experimental, so prefer imagetools inspect in scripts.
Compare the digest from either command with the one printed by docker push. If they differ, the tag has been overwritten since your push, possibly by a teammate or a CI job.
Prove it by pulling
The spine's example removes the local tag, pulls, and runs:
docker rmi YOUR_USERNAME/myapp:1.0
docker pull YOUR_USERNAME/myapp:1.0
docker run --rm YOUR_USERNAME/myapp:1.0Run docker run and you should see:
Hello from Docker HubA gotcha: the first `rmi` does not remove the image
Earlier you created two names for one image: myapp:1.0 and YOUR_USERNAME/myapp:1.0. Both point to the same image ID. docker rmi YOUR_USERNAME/myapp:1.0 only removes that one name, which Docker reports as Untagged. The image and its layers stay on disk because myapp:1.0 still references them.
When you then run docker pull, Docker still contacts Docker Hub and resolves the tag to a digest. That confirms the manifest exists in the repository. But every layer is already present locally, so nothing is downloaded, and you will see:
1.0: Pulling from YOUR_USERNAME/myapp
Digest: sha256:3f1c0a9e5b7d4c2a8e6f1b0d9c7a5e3f2b4d6a8c0e1f3a5b7c9d1e3f5a7b9c1d
Status: Image is up to date for YOUR_USERNAME/myapp:1.0That is a valid result, but it does not prove the layers can be downloaded. For a full test, remove every name that refers to the image:
docker rmi YOUR_USERNAME/myapp:1.0 myapp:1.0
docker pull YOUR_USERNAME/myapp:1.0Now Docker has to fetch the layers, and the output includes lines such as Pull complete. In this chapter's image, the only layer is the Alpine base layer. The CMD line adds metadata and no filesystem layer. If you also have alpine:3.20 on your machine, that layer may be reused and not downloaded again.
Compare digests locally
After a pull, the local image records the repository digest it came from. Print it with:
docker image inspect --format '{{index .RepoDigests 0}}' YOUR_USERNAME/myapp:1.0The output has the form YOUR_USERNAME/myapp@sha256:.... The part after @ should equal the digest from your push. If you have tagged the image under several repositories, RepoDigests has several entries, and index 0 might not be the one you want. In that case, run the command without --format and read the list.
Pull by digest
A tag is a movable label, while a digest is not. To fetch exactly the image you pushed, even if the tag moves later:
docker pull YOUR_USERNAME/myapp@sha256:3f1c0a9e5b7d4c2a8e6f1b0d9c7a5e3f2b4d6a8c0e1f3a5b7c9d1e3f5a7b9c1dReplace the digest with your own. If this succeeds, the content you pushed is stored in the registry under that fingerprint. Deployments that need reproducibility often pin to digests for this reason.
Test as an outsider
You pushed while logged in, and pulls from your own machine can use your stored credentials. For a public repository, the real test is whether someone with no account can pull. Log out, remove the local copies, and pull again:
docker logout
docker rmi YOUR_USERNAME/myapp:1.0 myapp:1.0
docker pull YOUR_USERNAME/myapp:1.0For a public repository, this succeeds. For a private repository, it fails with an authorization error, which is the correct behavior. Log in again afterward with docker login -u YOUR_USERNAME.
If you can, repeat the pull on a different machine or in a throwaway container. A second environment catches problems that your own machine hides, such as a missing credential or a locally cached layer.
Reading pull errors
If verification fails, the error text points to the cause.
| Message (shortened) | Likely cause | What to check |
|---|---|---|
| `manifest unknown` or `not found` | The repository exists, but the tag does not. | Spelling of the tag. Run the tag listing on the Tags tab. |
| `pull access denied ... repository does not exist or may require authorization` | The repository name is wrong, or it is private and you are not logged in. | The namespace and repository spelling. Run `docker login`. |
| `requested access to the resource is denied` | You are authenticated as an account without permission. | The account you logged in with. |
| Pull succeeds but `docker run` prints a platform warning or `exec format error` | The image was built for a different CPU architecture. | The OS/Arch column on the Tags tab. See the multi-platform chapter. |
A name that omits the namespace, such as myapp:1.0, makes Docker look for docker.io/library/myapp, which is the area for official images. That almost never exists, so a pull of an unqualified name fails or fetches something unrelated.
A short verification routine
When you want a repeatable check after any push, use this sequence:
- Note the digest printed by
docker push. - Run
docker buildx imagetools inspect YOUR_USERNAME/myapp:1.0and confirm the same digest. - Remove every local name for the image.
- Run
docker pulland confirm aDigest:line that matches. - Run
docker run --rmand confirm the output is what the image should produce.
Steps 1 and 2 are cheap and suit scripts and CI jobs. Steps 3 to 5 cost bandwidth, so use them when you need the full proof, such as before a release.
Exercise
You run docker rmi YOUR_USERNAME/myapp:1.0 and then docker pull YOUR_USERNAME/myapp:1.0. The output ends with Status: Image is up to date, and no layers were downloaded. Does this prove that Docker Hub can serve every layer of the image? What should you do to get a stronger check?
Show answer
No. It proves only that Docker Hub has a manifest for the tag. The rmi removed just one name, and myapp:1.0 still referenced the image, so all layers stayed on disk. To test layer download, remove every name with docker rmi YOUR_USERNAME/myapp:1.0 myapp:1.0, then pull again. Pulling by digest is also fine.
Exercise
After a push, docker push printed a digest ending in ...c1d. Later, docker buildx imagetools inspect YOUR_USERNAME/myapp:1.0 shows a digest ending in ...9f2. What most likely happened, and how can you still retrieve the original image?
Show answer
The tag 1.0 was overwritten by another push after yours, so it now points to a different manifest. A tag can move, and a digest cannot. If the original digest is still stored in the registry, pull it with docker pull YOUR_USERNAME/myapp@sha256:<original digest>.