ARTIFACTORY: How to use Docker Engine API and Artifactory

AuthorFullName__c
Derek Pang
articleNumber
000005526
FirstPublishedDate
2022-12-23T08:08:42Z
lastModifiedDate
2025-05-15

ARTIFACTORY: How to use Docker Engine API and Artifactory

The Docker engine has an API that is able to be used with HTTP requests to the unix-socket. In this article, we will look at a simple example to do this with Artifactory.

Using the Docker Engine API to Pull an Image

The Docker Engine API to pull an image is the Create an Image api.
Your Artifactory instance most likely has access to authentication. You will need to pass your Authentication through the curl request (ref).

Here is an example of using the base64 encoded authentication:

export JSON=$(echo '{"username": "<USER>", "password": "<PASSWORD>", "serveraddress": "<JFROG_URL>"}' | base64)


Then you can run the ImageCreate endpoint with the authentication 
 

curl --unix-socket /var/run/docker.sock -H "Content-Type: application/tar" -XPOST "http://localhost/v1.41/images/create?fromImage=<JFROG_URL>/<REPO_NAME>/<IMAGE_NAME>:<TAG>" -H "X-Registry-Auth: $JSON"


Note: for the parameter of fromImage, it would be the value that you pull the image with. This means that the formatting can change depending on Docker access method. The above example is the formatting of the repository path method. The fromImage parameter should be according to what Docker access method you have configured so if you have SubDomain configured you would use <REPO_NAME>.<JFROG_URL>/<IMAGE>:<TAG> instead.

You can find what format the Image should be on the HTTP Settings page (Administration -> Services/Artifactory -> General/HTTP Settings).

User-added image