如何为 gitlab-runner 服务的 docker-compose 文件中的 $DOCKER_VOLUMES 变量提供多个地址

问题描述 投票:0回答:1

根据gitlab-runner文档;为了访问执行器容器内的特定卷,您可以在注册运行器时添加以下选项:

--docker-volumes 值

绑定挂载一个卷,如果挂载前不存在则创建它。每个挂载点可以多次指定,例如--docker-volumes 'test0:/test0' --docker-volumes 'test1:/test1' 或使用 $DOCKER_VOLUMES 作为环境变量。

现在的问题是,如果我们想通过 $DOCKER_VOLUMES 环境变量来绑定挂载多个卷,我们应该如何使用它?

git docker docker-compose gitlab gitlab-ci-runner
1个回答
0
投票

这是我找到的最干净的解决方案。在模板配置中指定卷并将其传递给注册命令: https://docs.gitlab.com/runner/register/index.html#runners-configuration-template-file

cat > /etc/gitlab-runner/test-config.template.toml << EOF
[[runners]]
  [runners.docker]
    volumes=["/path/to/file:/path/to/file","/path/to/file2:/path/to/file2:ro", "/cache"]
EOF

gitlab-runner register --non-interactive --template-config /etc/gitlab-runner/test-config.template.toml
© www.soinside.com 2019 - 2024. All rights reserved.