Docker Push Command
# Docker push Command
[Docker Command Manual](#)
* * *
The `docker push` 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 NAME[:TAG]
* **`NAME`**: The image name, typically including the registry address (e.g., `docker.io/myrepo/myimage`).
* **`TAG`** (optional): The image tag, defaulting to `latest`.
OPTIONS description:
* **--disable-content-trust :**Skip image verification, enabled by default
**1. Push an 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 a custom registry**
docker push myregistry.com/myrepo/myimage:mytag
This will push the local myrepo/myimage:mytag image to the myregistry.com registry.
## Examples
### Pushing 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
Output example:
The push refers to repository [docker.io/myrepo/myimage] d1e017099d17: Pushed1.0: digest: sha256:12345abcdef... size: 1234
### Pushing an Image to a 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
### Important Notes
* Ensure you are logged in to the target registry (using the `docker login` command).
* 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.
The `docker push` command is a key tool for pushing local Docker images to a registry. By using this command, users can conveniently share, deploy, and manage Docker images. When using it, ensure correct login and tag settings to guarantee the image is pushed successfully to the target registry.
* * Docker Command Manual](#)
YouTip