<p>An image reference in docker doesn't contain the schema, so there's no <code>https://</code>. 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 <code>docker tag</code> to have the name you want to push. So your steps should be:</p>
<pre class="lang-yaml prettyprint-override"><code>    - docker login -u myPersonalAccessTokenUserName -p asdfasdfQn mygitserver.org
    - docker build -t mygitserver.org/jj/pipelinetests/widgetsimage .
    - docker push mygitserver.org/jj/pipelinetests/widgetsimage
</code></pre>

CC BY-SA 4.0
2022-04-21T13:19:47.970Z
Please see Edit 3
dot
CC BY-SA 4.0
2022-04-21T13:45:52.990Z
@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
CC BY-SA 4.0
2022-04-21T13:48:39.110Z
fair enough.  sounds good. thanks.
dot
CC BY-SA 4.0
2022-04-21T00:18:35.540Z
2022-04-21T00:18:35.540Z
BMitch
<p>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.</p>
<p>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:</p>
<pre><code>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></pre>
<p><strong>Code</strong></p>
<pre><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
</code></pre>
<p>I do see the Packages &amp; 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.</p>
<p><strong>EDIT 1</strong></p>
<p>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.</p>
<p><a href="https://i.sstatic.net/iKzi9.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iKzi9.jpg" alt="enter image description here" /></a></p>
<p>Also in case it's related ...
The URL for the project in gitlab is:</p>
<pre><code> https://mygitserver.org/JJ/pipelinetests
</code></pre>
<p>aka.  I have Uppercase in my path. But the docker login command never complains about the lower/uppercase.  I've tested with both.<br />
it always says it was successful:</p>
<pre><code>Executing &quot;step_script&quot; 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
</code></pre>
<p><strong>EDIT 2</strong></p>
<p>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:</p>
<pre><code>https://mygitserver.org/jj/pipelinetests/-/packages/widgetimage
</code></pre>
<p>But still no dice.</p>
<p><strong>EDIT 3</strong></p>
<p>So I tried to change my code like this:</p>
<pre><code>- docker login -u myPersonalAccessTokenUserName -p asdfasdfQn mygitserver.org
- docker build -t mygitserver.org/jj/pipelinetests/widgetsimage .
- docker push mygitserver.org/jj/pipelinetests/widgetsimage
</code></pre>
<p>But I'm basically getting a 404 / permissions error.</p>
<pre><code>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 '&lt;' looking for beginning of value: &quot;&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n  &lt;meta content=\&quot;width=device-width, initial-scale=1, maximum-scale=1\&quot; name=\&quot;viewport\&quot;&gt;\n  &lt;title&gt;The page you're looking for could not be found (404)&lt;/title&gt;\n  &lt;style&gt;\n    body {\n      color: #666;\n      text-align: center;\n      font-family: \&quot;Helvetica Neue\&quot;, 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  &lt;/style&gt;\n&lt;/head&gt;\n\n&lt;body&gt;\n  &lt;a href=\&quot;/\&quot;&gt;\n    &lt;img src=\&quot;data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEwIiBoZWlnaHQ9IjIxMCIgdmlld0JveD0iMCAwIDIxMC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=\&quot;\n       alt=\&quot;GitLab Logo\&quot; /&gt;\n  &lt;/a&gt;\n  &lt;h1&gt;\n    404\n  &lt;/h1&gt;\n  &lt;div class=\&quot;container\&quot;&gt;\n    &lt;h3&gt;The page could not be found or you don't have permission to view it.&lt;/h3&gt;\n    &lt;hr /&gt;\n    &lt;p&gt;The resource that you are attempting to access does not exist or you don't have the necessary permissions to view it.&lt;/p&gt;\n    &lt;p&gt;Make sure the address is correct and that the page hasn't moved.&lt;/p&gt;\n    &lt;p&gt;Please contact your GitLab administrator if you think this is a mistake.&lt;/p&gt;\n    &lt;a href=\&quot;javascript:history.back()\&quot; class=\&quot;js-go-back go-back\&quot;&gt;Go back&lt;/a&gt;\n  &lt;/div&gt;\n  &lt;script&gt;\n    (function () {\n      var goBack = document.querySelector('.js-go-back');\n\n      if (history.length &gt; 1) {\n        goBack.style.display = 'inline';\n      }\n    })();\n  &lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n&quot;
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
</code></pre>
<p>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?</p>

<docker><gitlab><gitlab-ci-runner><docker-registry>
gitlab project registry - docker push fails with invalid reference format error message
dot
# gitlab project registry - docker push fails with invalid reference format error message

(Asked by: username_0 on 2022-04-20)

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 '<' looking for beginning of value: "\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    The page could not be found or you don't have permission to view it.\n    \n    The resource that you are attempting to access does not exist or you don't have the necessary permissions to view it.\n    Make sure the address is correct and that the page hasn't moved.\n    Please contact your GitLab administrator if you think this is a mistake.\n    Go back\n  \n  \n\n\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?

**Tags:** docker, gitlab, gitlab-ci-runner, docker-registry


---

## 1 answers

### Answer by username_1 on 2022-04-21. Score: 0 | Accepted answer

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

> **Comments:**
> **username_0**: Please see Edit 3  
> **username_1**: @username_0 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.  
> **username_0**: fair enough.  sounds good. thanks.  

---

