Learn How to Use Artifactory as a Docker Registry
Tags: devops, tutorial, productivity, cloud
Published: 2023-04-01 05:27:15

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. 

## Prerequisites
- Free [Harness account](https://www.harness.io/products/continuous-integration?module=ci?utm_source=internal&utm_medium=social&utm_campaign=devadvocacy&utm_content=pavan_artifactory_article&utm_term=get-started) to push our artifacts
- Free [JFrog Artifactory](https://jfrog.com/artifactory/) account
- A sample application. Fork this [sample Node.js application](https://github.com/pavanbelagatti/Simple-Node-App) 


## Tutorial
Sign in to your Harness account and select the Continuous Integration module.
![Harness account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bojcp3nsu3y52r7bedd8.png)

Start creating your first pipeline
![first pipeline](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr2quy5qww186x6fmshw.png)

Select the code repository system. Our code is on GitHub and hence we select GitHub from this list
![repo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2gkk5zxx8nvyne2y1qzi.png)

Add the access token from your GitHub and authenticate the GitHub. Make sure the connection is successful.
![github auth](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hhxm4ndkack62w6qtzz.png)

Select the repo we are working on. Hope you have forked our [sample Node.js application repo](https://github.com/pavanbelagatti/Simple-Node-App). 
![selecting node repo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5t90rg57i2ffiqoisoz.png)

Next, select Node.js from the list as our application is a Node.js application.
![nodejs app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zzzhq9vv6h2yhwf4pdwo.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pc2n8ny33yvpdi051vgp.png)

Click on 'Create Pipeline' and you will land on the pipeline studio that looks like below
![pipeline studio](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ungsh64hm25f79tbzsd.png)

When you click on the 'Build Node App' stage, you should see a default step configured already. That is 'Build Node App'.
![default step](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7axkk59jqakhporp5c3l.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1qlsx297r708l43npd5.png)

Now, let's go back to our main pipeline studio and add a step to add the Artifactory.
![add artifactory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rtv956b9kwqjean54w1s.png)

Click on 'Add Step' and you will be presented with various options from the step library. Select 'Upload artifact to JFrog Artifactory'.
![step library](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/29vhpagt0iow6cxh4n7u.png)

Add all the required details
![artifactory step details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ayzio77k45c3j3qr3nfb.png)

Do you see that Artifactory connector? We have not connected our Artifactory yet. Let's do it by adding new connector.
![artifactory connector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xcgu9mb1jbbaun21l4aq.png)

Add the connector details, starting with the name.
![connector name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pv9357tnhcfmyhliexjs.png)

If you don't have a Artifactory account, create one, it is free.
![artifactory account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7iblo0tnvxoinzg3s3mv.png)

Sign in and select Docker from the package type.
![docker package type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vhwhxxwtrmljky2zo2lc.png)

Create a Docker registry
![docker registry](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlleq4e31zd3e712ytzi.png)

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.
![setup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8r6pf1ud04g3dvbl64t.png)

![docker registry setup commands](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jo778uy2zz8pcu1ml9mh.png)

Finally, this is what you can see:)
![registry](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsy768a8r7brksglmyrt.png)

You need to make a note of your API key, which is your password.
![API key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmf1e7qis9dbbwyvwzh3.png)

We are done with setting up the Docker registry in Artifactory.
![set docker registry](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22umpll6ie0wm3avwcqs.png)

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

![secret api](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3p0gcgt058mril4euhlq.png)

Add all the details and continue.
![artifactory connect details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ck12jf37j4x6qxpkjdm5.png)

In the connect to provider, select 'Connect through Harness Platform'
![provider](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gt13kl4cq1pbuyp6ppod.png)

Make sure the connection is successful.
![successful connection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6056yjg6jlbbtoihnf1l.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ubjwlicj8q59d630kksz.png)

Apply changes, save everything and run the pipeline.
![run pipeline](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yymppr6zvsv3jvixo2th.png)

You should see a successful pipeline execution.
![successful pipeline execution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8qf1zyh1klucilqurvm.png)

In the console view, you can see the last step, i.e Artifactory step. 
![artifactory step](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zi1dor8ukng7hhe5ycr.png)

You can verify if the artifact pushed by going to your Artifactory dashboard. You should see our package.json pushed.
![artifact pushed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6jqh2ty2o2g2awiir730.png)

_**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
{% embed https://dev.to/pavanbelagatti/learn-how-to-setup-a-cicd-pipeline-from-scratch-for-a-go-application-4m69 %}