0

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.

enter image description here

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 '<' looking for beginning of value: "<!DOCTYPE html>\n<html>\n<head>\n  <meta content=\"width=device-width, initial-scale=1, maximum-scale=1\" name=\"viewport\">\n  <title>The page you're looking for could not be found (404)</title>\n  <style>\n    body {\n      color: #666;\n      text-align: center;\n      font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n      margin: auto;\n      font-size: 14px;\n    }\n\n    h1 {\n      font-size: 56px;\n      line-height: 100px;\n      font-weight: 400;\n      color: #456;\n    }\n\n    h2 {\n      font-size: 24px;\n      color: #666;\n      line-height: 1.5em;\n    }\n\n    h3 {\n      color: #456;\n      font-size: 20px;\n      font-weight: 400;\n      line-height: 28px;\n    }\n\n    hr {\n      max-width: 800px;\n      margin: 18px auto;\n      border: 0;\n      border-top: 1px solid #EEE;\n      border-bottom: 1px solid white;\n    }\n\n    img {\n      max-width: 40vw;\n      display: block;\n      margin: 40px auto;\n    }\n\n    a {\n      line-height: 100px;\n      font-weight: 400;\n      color: #4A8BEE;\n      font-size: 18px;\n      text-decoration: none;\n    }\n\n    .container {\n      margin: auto 20px;\n    }\n\n    .go-back {\n      display: none;\n    }\n\n  </style>\n</head>\n\n<body>\n  <a href=\"/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4NiA2LjQxMS0zLjY4NSA3LjYwOCAwbDIzLjI3MiA3MS42MjV6IiBmaWxsPSIjZTI0MzI5Ii8+Cjwvc3ZnPgo=\"\n       alt=\"GitLab Logo\" />\n  </a>\n  <h1>\n    404\n  </h1>\n  <div class=\"container\">\n    <h3>The page could not be found or you don't have permission to view it.</h3>\n    <hr />\n    <p>The resource that you are attempting to access does not exist or you don't have the necessary permissions to view it.</p>\n    <p>Make sure the address is correct and that the page hasn't moved.</p>\n    <p>Please contact your GitLab administrator if you think this is a mistake.</p>\n    <a href=\"javascript:history.back()\" class=\"js-go-back go-back\">Go back</a>\n  </div>\n  <script>\n    (function () {\n      var goBack = document.querySelector('.js-go-back');\n\n      if (history.length > 1) {\n        goBack.style.display = 'inline';\n      }\n    })();\n  </script>\n</body>\n</html>\n"
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1

I 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?

1 Answer 1

0

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 with docker 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
3
  • Please see Edit 3
    – dot
    Apr 21, 2022 at 13:19
  • @dot the new error indicates you are not talking to the container registry on mygitgserver.org:443. Docker pushes to a registry API, so you'll need to check that the registry service is running and on what port. That said, your original question should be considered answered. Please do not merge multiple questions as it makes them less useful to future visitors solving your original issue. Open separate questions and check that your question has not already been asked.
    – BMitch
    Apr 21, 2022 at 13:45
  • fair enough. sounds good. thanks.
    – dot
    Apr 21, 2022 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.