Quick Start with Docker
The Harness Artifact Registry module allows you to quickly and easily store your digital artifacts.
Use this docker quick start guide to learn what the module has to offer and how to use it.
Prerequisite
This quick start guide requires the use of docker, so ensure that you can use the docker CLI.
Creating a registry
This first section will go over how to create and configure a registry for use.
Enable and select the module
You can find the Artifact Registry module in the module selector in the left nav.
Create a docker registry
- Select + New Artifact Registry under the Registries tab.
- Select a registry type. In this guide, we will use Docker.
- Enter a Registry Name and, optionally, a Description or Labels.
tip
This registry name must start with a letter and can only contain lowercase alphanumerics,
_
,.
and-
- Select Create Registry.
Create a docker upstream proxy
An Upstream Proxy for an Artifact Registry is a proxy configuration that allows the registry to fetch artifacts from another external or remote registry. When a user requests an artifact that isn't available in the registry, the registry directs the request to a configured upstream proxy. To create one, follow these steps:
- Interactive guide
- Step-by-step
-
Select the dropdown next to + New Artifact Registry, and then select Upstream Proxy.
-
Enter the Upstream Proxy Key. This is the identifier or name for the proxy within Harness and is chosen by you.
allowed charactersThis proxy key must start with a letter and can only contain lowercase alphanumerics,
_
,.
and-
-
For the source, select Docker Hub.
-
Choose your Authentication method. In this case, we only want to use public docker images, so we will select Anonymous.
-
Select Create Upstream Proxy.
Set the upstream proxy
After creating an upstream proxy, you need to set it in your artifact registry. To do so, follow these steps:
- In the docker registry we created above, select Configuration.
- Open the Advanced (Optional) dropdown menu.
- Select Configure Upstream.
- Under Available upstream proxies, you will see a list of available upstream proxies. Select as many as you would like.
- Under Selected proxies, you will see an ordered list of selected proxies for this registry. When the registry receives a request, the proxies will be queried in order from top to bottom.
- Click Save in the top right corner.
Use a registry
Next, lets use the registry we created. To do so, we will pull an artifact from the proxy, tag it, and add it to our registry.
Operations that interact with your registry all start with the Setup Client button in the top right corner of your registry.
Login to your registry
- Click Setup Client.
- Copy the docker login command shown. It should look something like:
docker login pkg.app.harness.io
- Then, open a terminal window and paste the command.
- When prompted, enter the username given in the Setup Client tab.
- When prompted for a password, click Generate Token in the Setup Client tab. Use this token as your password.
Pull an image
Next, we will try and pull an image from your registry.
- Open the Setup Client tab in your registry.
- Scroll to the bottom and find the Pull an image section.
- Copy the pull image command. It should look something like this:
docker pull pkg.qa.harness.io/<ACCOUNT_ID>/docs-registry/<IMAGE_NAME>:<TAG>
- Run the command in terminal but replace
<IMAGE_NAME>:<TAG>
with the name and tag of the image you want to pull. In this case, we will pull the imagelibrary/nginx
with no tag. In the end, the command will look like this:
docker pull pkg.qa.harness.io/<ACCOUNT_ID>/docs-registry/library/nginx
This first attempts to pull the image from the registry docs-registry
but the image doesn't exist. Therefore, it will check the proxy next and find it in DockerHub.
Push an image
Next, we will tag and push the nginx image to the registry to store it in Harness.
- Open the Setup Client tab in your registry.
- Find the Retag and Push the image section.
- Copy the tag image command. It should look like this:
docker tag <IMAGE_NAME>:<TAG> pkg.qa.harness.io/<ACCOUNT_ID>/docs-registry/<IMAGE_NAME>:<TAG>
- Replace
<IMAGE_NAME>
withnginx
and the second<TAG>
withtest
.<ACCOUNT_ID>
should be filled for you. The command will look like this:
docker tag nginx pkg.qa.harness.io/<ACCOUNT_ID>/docs-registry/nginx:test
- Copy the push image command and make the replacements, it will look like this:
docker push pkg.qa.harness.io/<ACCOUNT_ID>/docs-registry/nginx:test
Now, you should see the artifact appear in your docker registry as well as the Artifacts tab in the left navigation panel.
That concludes the quick start guide! You should now have enough to get started with Artifact Registry.
See Also
To learn more go to: