Trying to transform a project in gitlab to docker image. The gitlab is selfhosted. This is the error I get:
Running with gitlab-runner 13.12.0 (7a6612da)
on test -KnwQXuT
Preparing the "docker" executor
ERROR: Failed to remove network for build
ERROR: Preparation failed: Got permission denied while trying to connect to the Docker daemon
socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: dial
unix /var/run/docker.sock: connect: permission denied (docker.go:858:0s)
I added a runner,registered it, created a gitlab-ci.yml with docker template which I left unmodified. As solutions I tried chmod 666 /var/run/docker.sock
before and after adding the runner but it did not work. I also added sudo before running and registering the docker runner but still no success. I found another option to add my docker user to group docker but all my users are in the docker group. The docker runner is run as a docker image. I did not know what to do...Please help. I`m am trying for about 10 days with no success... Thanks in advance
sudo groupadd docker
sudo usermod -aG docker ${USER}
sudo chmod 666 /var/run/docker.sock
sudo systemctl restart docker
When you use gitlab self-hosted runner, by default, it creates a user named gitlab-runner . You need to assign the permissions to it.
sudo usermod -aG docker gitlab-runner
this will assign the correct permissions to the gitlab-runner and should pull the docker images on that VM.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.