GitLab CI Runner,如何在服务容器中使用卷或挂载 [英] GitLab CI Runner, how to use volumes or mounts in service containers
问题描述
我使用GitLab CI Runner,它使用以下命令:
I use GitLab CI Runner, it uses the command:
docker run -d --name postgres postgres:9.4
我想做这样的事情:
docker run -d --name postgres --volumes-from postgres_datastore postgres:9.4
但是GitLab CI Runner不支持(-v或--volumes-from)
的任何选项。
But GitLab CI Runner doesn't support any options (-v or --volumes-from)
.
还有其他方法吗?
推荐答案
Docker volumes-from
选项在Gitlab CI Runner中尚不可用(请参阅此 PR ),但是您可以配置主机挂载和卷:
The Docker volumes-from
option is not yet available in Gitlab CI Runner (see this PR), however you can configure host mounts and volumes:
[runners.docker]
volumes = ["/host/path:/target/path:rw", "/some/path"]
上面的示例将 / host / path
安装在容器内的 / target / path /
处,在 / some / path
处新建一个卷容器。
The above example would mount /host/path
at /target/path/
inside the container and also create a new volume container at /some/path
.
请参阅Gitlab CI Runner 手册 docker相关选项。
See the Gitlab CI Runner manual for all docker related options.
编辑:
对于服务容器,您似乎可以仅通过服务映像的dockerfile定义卷。也许足够,取决于您的要求。
For service containers it seems you can only define volumes via the dockerfile of the service image. Maybe enough depending on your requirements.
这篇关于GitLab CI Runner,如何在服务容器中使用卷或挂载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!