gpt4 book ai didi

docker - 如何在CircleCI配置中为Docker容器指定卷?

转载 作者:行者123 更新时间:2023-12-02 21:20:16 28 4
gpt4 key购买 nike

我没有设法找出如何在config.yml中安装docker镜像卷以与CircleCI集成。

官方文件为
container usage,入口点,命令等,但与卷安装无关。

场景是,我的项目的构建需要两个docker容器,一个是主容器,另一个是用于服务foo的容器。要使用服务foo,我需要将前面步骤中生成的一些 Artifact 暴露给foo容器,然后执行一些后续步骤。

有人知道我是否可以这样做吗?

最佳答案

如从CircleCI documentation截取的:

Mounting Folders
It’s not possible to mount a folder from your job space into a container in Remote Docker (and vice versa). But you can use docker cp command to transfer files between these two environments. For example, you want to start a container in Remote Docker and you want to use a config file from your source code for that:

- run: |
# creating dummy container which will hold a volume with config
docker create -v /cfg --name configs alpine:3.4 /bin/true
# copying config file into this volume
docker cp path/in/your/source/code/app_config.yml configs:/cfg
# starting application container using this volume
docker run --volumes-from configs app-image:1.2.3
In the same way, if your application produces some artifacts that need to be stored, you can copy them from Remote Docker:

- run: |
# starting container with our application
# make sure you're not using `--rm` option otherwise container will be killed after finish
docker run --name app app-image:1.2.3

- run: |
# once application container finishes we can copy artifacts directly from it
docker cp app:/output /path/in/your/job/space

关于docker - 如何在CircleCI配置中为Docker容器指定卷?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46514380/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com