Docker push command
docker pushThe 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 on other systems or environments.
Syntax
docker push [OPTIONS] NAME[:TAG]
NAME: image name, usually including the registry address (e.g.docker.io/myrepo/myimage)。TAG(Optional): image tag, defaults tolatest。
OPTIONS description:
--disable-content-trust :Ignore image verification, enabled by default
1. Push the image with the default tag (latest)
docker push myrepo/myimage
This will push the local myrepo/myimage:latest image to Docker Hub.
2. Push an image with a specific tag
docker push myrepo/myimage:1.0
This will push the local myrepo/myimage:1.0 image to Docker Hub.
3. Push to custom registry
docker push myregistry.com/myrepo/myimage:mytag
This will push the local myrepo/myimage:mytag image to the myregistry.com registry.
Example
Push 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
Output example:
The push refers to repository [docker.io/myrepo/myimage] d1e017099d17: Pushed 1.0: digest: sha256:12345abcdef... size: 1234
Push the image to the custom registry
1. Log in to the custom registry
docker login myregistry.com
2. Build an image
docker build -t myregistry.com/myrepo/myimage:mytag .
3. Push the image to the custom registry
docker push myregistry.com/myrepo/myimage:mytag
Output example:
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 (using
docker logincommand). - Before pushing an image, ensure the image tag is correct and complies with the registry's naming conventions.
- The push operation requires a network connection. Image size and network speed will affect the push time.
- For private registries, ensure you have the appropriate access permissions and configuration information.
docker pushThe command is a key tool for pushing local Docker images to a registry. By using this command, users can easily share, deploy, and manage Docker images. When using it, ensure correct login and tag settings so that the image can be pushed to the target registry correctly.
other extensions