2 minute read
This is the basic usage provided by Harbor, store container images in a self-hosted registry.
- Docker to push container images to your registry (not tied to use docker but skopeo/kaniko…)
- Connectivity to the registry (including credentials)
Make sure you know the Harbor external hostname, username, and password.
Let’s assume these values in this example:
Then log in to the registry:
$ docker login harbor.example.com -u admin -pHarbor12345 WARNING! Using --password via the CLI is insecure. Use --password-stdin. Login Succeeded
In the default registry installation, a Harbor project is created named
library. We are going to use this project
to push images.
Then, let’s tag a container image. It does not matter if you download an existing one from Docker Hub/Quay or you build your image.
Let’s download an old
ubuntu container image from Docker Hub (16.04).
We are going to use this image in the clair page.
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE $ docker pull ubuntu:16.04 16.04: Pulling from library/ubuntu e92ed755c008: Pull complete b9fd7cb1ff8f: Pull complete ee690f2d57a1: Pull complete 53e3366ec435: Pull complete Digest: sha256:db6697a61d5679b7ca69dbde3dad6be0d17064d5b6b0e9f7be8d456ebb337209 Status: Downloaded newer image for ubuntu:16.04 docker.io/library/ubuntu:16.04 $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 16.04 005d2078bdfa 2 weeks ago 125MB
Now, we have a local copy of the
ubuntu:16.04 container image. Let’s tag the image to push it to your registry.
You can see these commands in your Harbor instance:
$ docker tag ubuntu:16.04 harbor.example.com/library/ubuntu:16.04 $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 16.04 005d2078bdfa 2 weeks ago 125MB harbor.example.com/library/ubuntu 16.04 005d2078bdfa 2 weeks ago 125MB
Note that the image id is the same in both tags.
Time to push it to the registry
$ docker push harbor.example.com/library/ubuntu:16.04 The push refers to repository [harbor.example.com/library/ubuntu] 64d2e4aaa54c: Pushed 0d3833376c2f: Pushed 4a048ea09024: Pushed b592b5433bbf: Pushed 16.04: digest: sha256:a4fc0c40360ff2224db3a483e5d80e9164fe3fdce2a8439d2686270643974632 size: 1150
The container image is now available in your registry. You can find it in the Harbor UI:
Feel free to continue to the notary section to sign the image.
Was this page helpful?
Glad to hear it! Thanks for letting us know!
Sorry to hear that. Please tell us how we can improve.