首页 > 解决方案 > 在 gitlab shell 执行程序中运行 docker 时权限被拒绝

问题描述

我在树莓派上部署了 gitlab shell 执行器。我在 pi 上有本地设置,比如 docker。我想运行使用docker.

.gitlab-ci.yml

stages:
  - build
  - test

build:
  stage: build
  script:
    - docker -v
    - docker build . -t pskp:latest-1

test:
  stage: test
  script:
    - ls
    - echo $PATH

但我收到错误permission denied

Running with gitlab-runner 13.12.0 (7a6612da)
  on raspberry pi runner for rhombus Jr7gZD4G
Preparing the "shell" executor 
Using Shell executor...
Preparing environment 
Running on raspberry-pi...
Getting source from Git repository 
Fetching changes with git depth set to 50...
Initialized empty Git repository in /home/gitlab-runner/builds/Jr7gZD4G/0/rhombus4/quiz-app/.git/
Created fresh repository.
Checking out 25baf93d as demo-cicd...
Skipping Git submodules setup
Executing "step_script" stage of the job script 
$ docker -v
Docker version 20.10.6, build 370c289
$ docker login -u $docker_username -p $docker_password
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: 
Post http://%2Fvar%2Frun%2Fdocker.sock/v1.24/auth: dial unix /var/run/docker.sock: connect: permission denied
Cleaning up file based variables 
ERROR: Job failed: exit status 1

我看到了一些在线解决方案,上面写着要授予sudogitlab-runner 权限。但我不想授予对管道的 root 访问权限,因为其他组成员可以访问和更改.gitlab-ci.yml

我只想运行 docker,因为我有所有本地设置,所以不需要更新或升级。

我正在ubuntu使用raspberry pi

标签: dockergitlabgitlab-cigitlab-ci-runner

解决方案


推荐阅读