Gitlab runner stucks in doing the job

I use GitLab runner in my server.
the executor is the shell.
I use docker for CI and CD. I log in to my project Container Registry pull the latest version of the project image and do my ci jobs on it.

At the very first time, the runner works fine and does all the jobs. But when I add a new runner in the project (or in the group), the runner will stuck in doing the job. It picks up the job but will stuck in the middle.
As you see, the runner stuck in the line 25 (sudo docker login …)
Does anyone know what the problem is?


I would say that the problem is the way you are attempting to login. That wouldn’t be the correct way to do it. The correct format for it would be:

    - echo "${TOKEN}" | docker login -u ${USERNAME} --password-stdin ${GITLAB_REGISTRY}

that is what I use to login to a docker registry in my .gitlab-ci.yml replace the variable names with the ones you use for the username, password/token and registry url.

I don’t use sudo in mine, so whether that is something else, since you may already be running as root anyway. So you can also try with or without sudo.