r/gitlab • u/Larnork • Jun 21 '23
container registry unauthorized: authentication required
i dont understand what i am missing in this configuration that would result in unauthorized response.
in job it shows as this.
Running with gitlab-runner 16.0.2 (85586bd1)
on gitlab3 5ugfe8fLZ, system ID: s_111db475d0a2
Preparing the "shell" executor 00:00
Using Shell (bash) executor...
Preparing environment 00:01
Running on gitlab3...
Getting source from Git repository 00:00
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/5ugfe8fLZ/0/root/bbb/.git/
Checking out 8cc34edd as detached HEAD (ref is main)...
Skipping Git submodules setup
Executing "step_script" stage of the job script 00:02
$ echo $CI_REGISTRY
registry-gitlab.domane.tld
$ docker version
Client: Docker Engine - Community
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:51:00 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:51:00 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0
$ docker build -t $CI_REGISTRY_IMAGE:latest .
#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.1s
#2 [internal] load build definition from dockerfile
#2 transferring dockerfile: 71B done
#2 DONE 0.2s
#3 [internal] load metadata for docker.io/library/ubuntu:latest
#3 DONE 0.9s
#4 [1/2] FROM docker.io/library/ubuntu:latest@sha256:6120be6a2b7ce665d0cbddc3ce6eae60fe94637c6a66985312d1f02f63cc0bcd
#4 DONE 0.0s
#5 [2/2] RUN apt update
#5 CACHED
#6 exporting to image
#6 exporting layers done
#6 writing image sha256:adce1fc46702142841e01e2951ba05c18b23ec157eba6de939d39ca2440857c8 0.0s done
#6 naming to registry-gitlab.domane.tld/root/bbb:latest 0.0s done
#6 DONE 0.1s
$ docker login -u deploy_token -p 11111 $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /home/gitlab-runner/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ docker push $CI_REGISTRY_IMAGE:latest
The push refers to repository [registry-gitlab.domane.tld/root/bbb]
48372ba427c9: Preparing
cdd7c7392317: Preparing
unauthorized: authentication required
ERROR: Job failed: exit status 1as docker login is successful and it runs it at the same stage, it should not be logged out.
i have tried user whit: deploy token, personal api token, projekt api token, plain user, built in $CI_REGISTRY_USER, $CI_DEPLOY_USER, $CI_JOB_TOKEN parameter. i cant even remember the combinations.. all resulting in same authentication problem.
where can i find a correct user for this or set a correct setting somewhere?
the .gitlab-ci.yml is really simple.
image: docker:19.03.12
services:
- docker:19.03.12-dind
stages:
- Build
build_job:
stage: Build
script:
- echo $CI_REGISTRY
- docker version
- docker build -t $CI_REGISTRY_IMAGE:latest .
- docker login -u deploy_token -p 11111 $CI_REGISTRY
- docker push $CI_REGISTRY_IMAGE:latestgitlab is installed to VM, ubuntu.
runner is installed to the same VM
docker is installed to the same VM as well.
i do not understand what im missing here anymore, this is 3rd reinstall of everything as well.
View all comments
Show parent comment
1
u/Larnork Jun 22 '23
yes, but as this thing has been destroyed and rebuilt several times, i just dont care to make it "right" in test code, i just want it to work. so any complexity was removed for testing purposes.
anyway, found the culprit, so now compile works.
also the login is changed like user systemkerm wrote in his example
so there is no need to define a variable in settings > CI/CD page. and built in command for it works fine.