Pushing an Image to the Container Registry¶
After creating managed Harbor and registry space, you can follow the instructions below to log in and push the image to the container registry or log in to native Harbor to view the guidance provided by native Harbor under each registry space (project).
Push method 1¶
Prerequisites: Managed Harbor and registry space have been created.
You can build a new container image locally or grab a public image from DockerHub for testing. This page takes the latest official Nginx image of DockerHub as an example. Run the following commands in sequence in the command line tool to push the image. Please replace "library" and "nginx" with the name of the registry space and container registry you actually created.
-
Log in to the container registry using the following command:
Example:
Enter the container registry password in the returned result (the password set when creating managed Harbor).
-
Tag the image using the following command:
docker tag <container registry name>:<artifact version> <container registry address>/<registry space name>/<container registry name>:<artifact version>
Example:
-
Push the image to the registry space library using the following command:
docker push <container registry address>/<registry space name>/<container registry name>:<artifact version>
Example:
-
Pull the image using the following command:
docker pull <container registry address>/<registry space name>/<container registry name>:<artifact version>
Example:
Push method 2¶
Prerequisites: Managed Harbor and registry space have been created.
-
On the Managed Harbor list page, click ... on the right side of the target registry, then click Native Harbor to enter the login page of the native Harbor.
-
Enter the username and password set when creating managed Harbor to enter native Harbor.
-
Click the name of the target registry space (project) to enter the registry space.
-
Click the push command on the right to view the push commands provided by native Harbor.
Tip
Compared with method 1, the push command of the native Harbor automatically fills in the address of the container registry and the name of the registry space.