docker - 在 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
我看到了一些在线解决方案,上面写着要授予sudo
gitlab-runner 权限。但我不想授予对管道的 root 访问权限,因为其他组成员可以访问和更改.gitlab-ci.yml
。
我只想运行 docker,因为我有所有本地设置,所以不需要更新或升级。
我正在ubuntu
使用raspberry pi
解决方案
推荐阅读
- python - 检查一个数组是否包含 Python 中另一个数组的任何元素
- node.js - 渲染 ejs 不再需要 path.join(__dirname, 'views') 吗?
- react-native - MapboxGL.PointAnnotation 在 MapboxGL.ImageSource 上不可见
- javascript - 如何使用javascript从视频中提取字幕流
- bash - 使用一个命令从字符串中删除和替换字符
- reactjs - 扩展默认 Material UI 主题
- firebase - 如何在 Firebase 函数中使用循环?
- security - Pine 脚本 - 安全功能在不同的时间范围内显示不正确
- ffmpeg - FFmpeg 过滤复杂音频
- typescript - TypeScript Array<>.reduce() 类型