DOCKER - 4 5 Push on Docker Hub
This lesson continues the previous one on image tags — now we push our tagged image to Docker Hub. Running docker image push myaccount/my-nginx straight away fails with access denied: Docker tried to push to your account, but you're not logged in. The CLI has docker login and docker logout commands; with a free Docker Hub account you can authenticate directly from the terminal.
Login, push, and add extra tags
docker login
docker image push myaccount/my-nginx
Once authenticated, the push succeeds. Refresh your Docker Hub profile and you'll see the new repository. Notice that we never created the repo manually — pushing a tagged image with a name like myaccount/my-nginx automatically creates a public repo, defaulting the tag to latest if none was supplied. You can later edit the repo description, set permissions, or add documentation through the Hub UI.
To add another tag to the same image and push it as well:
docker image tag myaccount/my-nginx myaccount/my-nginx:testing
docker image push myaccount/my-nginx:testing
The output shows "Layer already exists" for every layer except the new tag manifest — Docker doesn't re-upload the bytes, it just registers a new reference. Refresh Docker Hub and the new tag appears alongside latest.
docker login/docker logout— manage CLI credentials (session token stored locally)- Pushing a new tag like
myaccount/repoauto-creates the repo as public - For a private repo, create it on Docker Hub first with privacy set, then push — the bits won't go public mid-flight
- If you're on a shared machine, run
docker logoutso your session token isn't left behind
To recap: tags must follow the <user-or-org>/<repo>:<tag> format to be pushable, multiple tags can share one image ID, and the convention on Docker Hub is that latest points to the most recent stable release of your software.