TLDR: I try to push a docker image with curl, but the uploaded image is broken.
Context: Due to connectivity limitation, I have to access our Artifactory docker registry through an API gateway. Docker commands as login can’t work as it tries to connect to a subdomain (eg my-registry.public-domain.com).
I can push/pull files to/from artifactory using Artifactory API with curl/jfrog CLI. My goal is to push a valid docker image to this Artifactory using the API only.
What I did is:
Build the docker
docker build . --file Dockerfile -t helloworld:v1.1
Save the image to a local file
docker image save --output=helloworld-v1.1.tar helloworld:v1.1
Untar the .tar image
mkdir v1.1; tar -xvf helloworld-v1.1.tar -C v1.1
Upload each layer and the manifest.json to artifactory
jfrog rt upload "v1.1/*" my-registry/helloworld/ --url xyz.com/artifactory --user foo --password bar
(Previous command behave like a recursive curl put in the v1.1/ folder)
Result:
Each layer and the manifest .json have been uploaded on Artifactory but something is wrong. Docker info are empty:
Unable to extract Docker metadata for
'my-registry/helloworld/v1.1/'
And trying to pull the image from Openshift result in this error (It works with images uploaded the usual way on the same Artifactory):
Failed to pull image "my-registry.my-artifactory/helloworld:v1.1": rpc
error: code = Unknown desc = pinging container registry
l-docker-dev-workspace-dev.a-artifactory.vt.ch: invalid status code
from registry 400 (Bad Request)
Do you have any clue to explain such a behaviour? How can I transfer my .tar docker image to Artifactory to then be usable like any other image?
Any help is welcome,
Have a great day!
2
Answers
For anyone looking to do the same thing, this thread answered my questions: Docker Private Registry Image Upload
I had to modify the script, as some of the commands were failing, and also to enable the upload of a docker image with multiple layers, but this is it.
You cannot upload a .tar file to a Docker-Type repository.
If you want to "distort" the use of Docker, you should try to use a repository of Type Generic.
However, I do not suggest this solution; I would try to understand if possible to review the network configurations to be able to use Artifactory normally.