DEV Community

Cover image for Learn How to Use Artifactory as a Docker Registry
Pavan Belagatti
Pavan Belagatti

Posted on

Learn How to Use Artifactory as a Docker Registry

Artifactory is a highly versatile and effective tool that serves as an ideal Docker registry for managing and storing Docker images. With its support for multiple Docker repositories, advanced search functions, and comprehensive access control, Artifactory offers a range of features to simplify Docker registry management. Additionally, Artifactory supports Docker Content Trust, which enables users to sign and verify Docker images to ensure their authenticity and integrity. The tool also integrates seamlessly with popular development tools like Jenkins, Kubernetes, and Helm, making it an excellent solution for containerized application development and deployment. By utilizing Artifactory as a Docker registry, managing Docker images can be streamlined, resulting in improved efficiency and security in the development pipeline.

Docker registry can be used to push our artifacts.You need a CI/CD tool to push your artifacts, files, images, etc, to the Artifactory. In this tutorial, we will see how to create a Docker registry from Artifactory and push our artifacts into it using Harness CI. Harness is a leader in software continuous delivery and has a robust CI module.



Sign in to your Harness account and select the Continuous Integration module.
Harness account

Start creating your first pipeline
first pipeline

Select the code repository system. Our code is on GitHub and hence we select GitHub from this list

Add the access token from your GitHub and authenticate the GitHub. Make sure the connection is successful.
github auth

Select the repo we are working on. Hope you have forked our sample Node.js application repo.
selecting node repo

Next, select Node.js from the list as our application is a Node.js application.
nodejs app

Once you select Node.js from the list, you should see a default yaml on the right side. That is the yaml format of your pipeline. Yes, we have an option to edit and work through yaml also.
yaml format

Click on 'Create Pipeline' and you will land on the pipeline studio that looks like below
pipeline studio

When you click on the 'Build Node App' stage, you should see a default step configured already. That is 'Build Node App'.
default step

If you click on that step 'Build Node App', you will see the settings configured for you. You can see what's happening there:) Basically, the npm packages required for the application are getting installed, then the build and test is happening.
build and test step

Now, let's go back to our main pipeline studio and add a step to add the Artifactory.
add artifactory

Click on 'Add Step' and you will be presented with various options from the step library. Select 'Upload artifact to JFrog Artifactory'.
step library

Add all the required details
artifactory step details

Do you see that Artifactory connector? We have not connected our Artifactory yet. Let's do it by adding new connector.
artifactory connector

Add the connector details, starting with the name.
connector name

If you don't have a Artifactory account, create one, it is free.
artifactory account

Sign in and select Docker from the package type.
docker package type

Create a Docker registry
docker registry

It is a well-guided document that will guide you through a complete Docker registry setup. Run the commands shown in the guided document in your terminal.

docker registry setup commands

Finally, this is what you can see:)

You need to make a note of your API key, which is your password.
API key

We are done with setting up the Docker registry in Artifactory.
set docker registry

Let's get to our Artifactory connector setup and add the API key as a secret.

secret api

Add all the details and continue.
artifactory connect details

In the connect to provider, select 'Connect through Harness Platform'

Make sure the connection is successful.
successful connection

We successfully added the Artifactory connector.

Let's go back to the Artifactory step and add other details such as target and source path. Just for this example, we are going to push our package.json file contents to our newly created Docker registry from Artifactory. We have mentioned the same in the source path.
target and source path

Apply changes, save everything and run the pipeline.
run pipeline

You should see a successful pipeline execution.
successful pipeline execution

In the console view, you can see the last step, i.e Artifactory step.
artifactory step

You can verify if the artifact pushed by going to your Artifactory dashboard. You should see our package.json pushed.
artifact pushed

Congratulations! We successfully created a Docker registry from Artifactory and pushed our artifacts (package.json in this case) with the help of Harness.

This way, developers can easily build and push any artifacts by creating their own Docker registry with Artifactory and Harness.

I have also written a tutorial on setting up a CI/CD pipeline from scratch.
Take a look

Top comments (0)