Push docker image to private registry failed when using gitlab-runner user
I have added gitlab-runner to the docker group, but when I want to push the image to the private registry, it failed. I have tried to push the image manually, the result is as below:
docker login (gitlab-runner ok, root ok)
docker push (gitlab-runner failed, root ok)
Can someone give me a help?
---- output from shell executor -----
Running with gitlab-runner 12.3.0 (a8a019e0)
on shell HMSessf2
Using Shell executor...
Running on harbor...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /home/gitlab-runner/builds/HMSessf2/0/switch/learninggit/.git/
Created fresh repository.
From http://git.gdcni.cn/switch/learninggit
* [new branch] master -> origin/master
Checking out 16eb1cd8 as master...
Skipping Git submodules setup
$ shaid=$(git log --abbrev-commit --pretty=oneline -n 1 | awk -F " " '{print $1}')
$ cp /build/main-$shaid .
$ docker build -t learninggit:gitlab-$shaid --build-arg FILE=main-$shaid .
Sending build context to Docker daemon 138.2kB
Step 1/5 : FROM centos:7
---> 67fa590cfc1c
Step 2/5 : ARG FILE
---> Using cache
---> 533d208235e5
Step 3/5 : WORKDIR /usr/local/bin
---> Using cache
---> 6cd2f448a17b
Step 4/5 : COPY $FILE ./app
---> 6f075ad92c94
Step 5/5 : CMD ["./app"]
---> Running in 24d0da0e7430
Removing intermediate container 24d0da0e7430
---> 399b71785449
Successfully built 399b71785449
Successfully tagged learninggit:gitlab-16eb1cd
$ docker tag learninggit:gitlab-$shaid hub.gdcni.cn/switch/learninggit:gitlab-$shaid
$ docker push hub.gdcni.cn/switch/learninggit:gitlab-$shaid
The push refers to repository [hub.gdcni.cn/switch/learninggit]
051ca526d1bc: Preparing
877b494a9f30: Preparing
denied: requested access to the resource is denied
ERROR: Job failed: exit status 1
Edited by Rui Ding