Docker push Command
docker push The command is used to push (upload) locally built Docker images to a Docker registry (such as Docker Hub or a private registry). This allows images to be shared and used in other systems or environments.
Syntax
docker push [OPTIONS] NAME[:TAG]
NAME: Image name, usually including the registry address (such asdocker.io/myrepo/myimage)。TAG(Optional): Image tag, default islatest。
OPTIONS description:
-
--disable-content-trust :Ignore image verification, enabled by default
** 1. Push an image with the default tag (latest)**
docker push myrepo/myimage
This pushes the local myrepo/myimage:latest image to Docker Hub.
** 2. Push an image with a specific tag**
docker push myrepo/myimage:1.0
This pushes the local myrepo/myimage:1.0 image to Docker Hub.
** 3. Push to a custom registry**
docker push myregistry.com/myrepo/myimage:mytag
This pushes the local myrepo/myimage:mytag image to the myregistry.com registry.
Example
Push an image to Docker Hub
1. Log in to Docker Hub
docker login
2. Build an image
docker build -t myrepo/myimage:1.0 .
3. Push the image to Docker Hub
docker push myrepo/myimage:1.0
Example output:
The push refers to repository [docker.io/myrepo/myimage]
d1e017099d17: Pushed
1.0: digest: sha256:12345abcdef... size: 1234
Push an image to a custom registry
1. Log in to a custom registry
docker login myregistry.com
2. Build an image
docker build -t myregistry.com/myrepo/myimage:mytag .
3. Push the image to a custom registry
docker push myregistry.com/myrepo/myimage:mytag
Example output:
The push refers to repository [myregistry.com/myrepo/myimage]
d1e017099d17: Pushed
mytag: digest: sha256:67890abcdef... size: 5678
Notes
- Ensure you are logged in to the target registry (use
docker logincommand). - Before pushing an image, ensure the image tag is correct and complies with the registry's naming conventions.
- Pushing requires a network connection; image size and network speed affect push time.
- For a private registry, ensure you have the appropriate access rights and configuration information.
docker push The command is a key tool for pushing local Docker images to a registry. By using it, users can easily share, deploy, and manage Docker images. When using it, ensure correct login and tag settings so that images can be pushed properly to the target registry.
Docker Command Reference