I have a GitLab Runner using a Shell Executor that needs to build a Docker container. When it executes the first Docker command it gets this error:
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))
If I logon as the gitlab-runnner user and try to execute docker commands manually I get this error:
$ docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.47/containers/json": dial unix /var/run/docker.sock: connect: permission denied
A quick Google and I need to add the gitlab-runner to the Docker group to grant it permission to execute Docker:
sudo usermod -a -G docker $USER