CodeBlanks Logo Icon CodeBlanks

docker push

Learn to push images to a registry with docker push.

docker push

docker push uploads a local image to the registry. The image name must contain the target registry and account; for Docker Hub, user/repository:tag:

docker login
docker tag api:1.2.0 ali/api:1.2.0
docker push ali/api:1.2.0

Layers already in the registry aren't uploaded again (Layer already exists); only the changed ones go.

Pushing all tags

To push all tags of a repository at once, --all-tags is used. For another registry, the address is written at the start of the name:

docker push --all-tags ali/api
docker tag api:1.2.0 ghcr.io/ali/api:1.2.0
docker push ghcr.io/ali/api:1.2.0

Practice Publish to Docker Hub

Write three commands: log in to Docker Hub; tag the local api:1.3.0 image as ali/api:1.3.0; push it.

Starter code

terminal
# buraya yaz

Sample solution

terminal
docker login
docker tag api:1.3.0 ali/api:1.3.0
docker push ali/api:1.3.0

Expected output

Login Succeeded
The push refers to repository [docker.io/ali/api]
5f6e7d8c9b0a: Pushed
a2318d6c47ec: Layer already exists
1.3.0: digest: sha256:7b1c… size: 1789

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Why does docker push api:1.2.0 give "denied: requested access to the resource is denied"?

  • The image is too big
  • There is no internet
  • The tag is malformed
  • The name has no account, so it tries to push to library/api Correct answer

Explanation: It must first be tagged as user/api:1.2.0.

2 Push all tags of the repository.

Question
docker push ____ ali/api
Answer
docker push --all-tags ali/api

Explanation: --all-tags uploads every tag in the repository.

3 Match.

Term Meaning
docker login Authentication
docker tag Give the target name
docker push Upload
Layer already exists Skipped layer

All lessons in Beginner