gitlab project registry - docker push fails with invalid reference format error message
-
I have create a personal access token for my project. in my gitlab-ci.yml I'm trying to create a docker image and then save it in my project's repository.
I'm able to login - I see an explicit message saying Login Succeeded. Then it builds the image but when trying to push is where I see this error:
12 exporting layers #12 exporting layers 7.8s done #12 writing image sha256:5337a378e31dcb6f8ed2cae0ab82188273947b395d52908eb07e4777b028a8a4 done #12 naming to docker.io/library/widgetsimage done #12 DONE 7.9s Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them $ docker push https://mygitserver.org/jj/pipelinetests/widgetsImage invalid reference format
Code
stages: - build # - unit-test
BuildDockerImage:
stage: build
environment:
name: development
image: docker
services:
- docker:dind
script:
- docker login -u myPersonalAccessTokenUserName -p asdfasdfQn https://mygitserver.org/JJ/pipelinetests
- docker build -t widgetsimage .
- docker push https://mygitserver.org/jj/pipelinetests/widgetsimage
tags:
- mac-pipelines-shell
I do see the Packages & Registries option in my project - which I guess indicates its enabled? But the list of packages is empty, of course. Any suggestions would be appreciated.
EDIT 1
I've tried changing the permissions / visibility on the project from private to Internal - everyone with access should now be able to do mostly everything on this test repo. But it didn't fix the issue.
Also in case it's related ... The URL for the project in gitlab is:
https://mygitserver.org/JJ/pipelinetests
aka. I have Uppercase in my path. But the docker login command never complains about the lower/uppercase. I've tested with both.
it always says it was successful:Executing "step_script" stage of the job script $ docker login -u myPersonalAccessTokenUserName -p asdfasdfQn https://mygitserver.org/jj/pipelinetests WARNING! Using --password via the CLI is insecure. Use --password-stdin. Login Succeeded $ docker build -t widgetsimage . #1 [internal] load build definition from Dockerfile
EDIT 2
I've also tried to use the url that I see when i navigate to the packages in the Gitlab GUI for the docker push command, like so:
https://mygitserver.org/jj/pipelinetests/-/packages/widgetimage
But still no dice.
EDIT 3
So I tried to change my code like this:
- docker login -u myPersonalAccessTokenUserName -p asdfasdfQn mygitserver.org - docker build -t mygitserver.org/jj/pipelinetests/widgetsimage . - docker push mygitserver.org/jj/pipelinetests/widgetsimage
But I'm basically getting a 404 / permissions error.
12 exporting layers 8.2s done #12 writing image sha256:756f9fc8559519e6893f8a28f35a60c6cc28cb50be09351bdba33baafd4db4f7 done #12 naming to mygitgserver.org/jj/pipelinetests/widgetsimage done #12 DONE 8.2s Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them $ docker push mygitgserver.org/jj/pipelinetests/widgetsimage Using default tag: latest The push refers to repository mygitgserver.org/jj/pipelinetests/widgetsimage] 8704fdba6e23: Preparing 7621ddf6521a: Preparing 27e96e15eec9: Preparing 1e773440db1a: Preparing fecad1a1ae13: Preparing 6c882dfb600e: Preparing fd6a5c73e987: Preparing 6c882dfb600e: Waiting a45a618792f0: Waiting 6c946b32cfe2: Waiting 7dd4a3e7d836: Waiting error parsing HTTP 404 response body: invalid character '\n\n\n \n The page you're looking for could not be found (404)\n \n\n\n\n \n
\n \n
\n 404\n
\n\n\n \n\n\n" Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit status 1The page could not be found or you don't have permission to view it.
\n
\nThe resource that you are attempting to access does not exist or you don't have the necessary permissions to view it.
\nMake sure the address is correct and that the page hasn't moved.
\nPlease contact your GitLab administrator if you think this is a mistake.
\n Go back\nI googled around a bit and I guess it's still possible that the registry option in general for Gitlab needs to be configured. Is this true? Like I need to assign a specific port for the registry? wondering how I can check? I'm not a gitlab admin. I don't have access to the server config. But wondering if there's anything I can try / test that would conclusively prove that the registry hasn't been set up globally?
-
An image reference in docker doesn't contain the schema, so there's no
https://
. For a registry login, you login to the server only, not to the repository. And when building, the tag either needs to include the full image reference you want to later push, or you need to retag the image withdocker tag
to have the name you want to push. So your steps should be:- docker login -u myPersonalAccessTokenUserName -p asdfasdfQn mygitserver.org - docker build -t mygitserver.org/jj/pipelinetests/widgetsimage . - docker push mygitserver.org/jj/pipelinetests/widgetsimage