gpt4 book ai didi

docker - 使用 Concourse 的 docker 资源来获取要在 docker compose 中使用的容器

转载 作者:行者123 更新时间:2023-12-02 18:16:05 27 4
gpt4 key购买 nike

可以使用大厅的 docker 资源来获取要在 docker 中使用的容器来组合任务吗?目前我只是从我的私有(private) Docker 注册表中获取用于我的集成测试的容器,但是这样做连接/资源不会显示在大厅 UI 中。有任何想法吗?

这是我目前的任务:

---
platform: linux
inputs:
- name: devops-repo
- name:client-repo
params:
RUNNER_IMG:
CLIENT_IMG:
SERVER_IMG:
run:
path: sh
args:
- -exc
- |
# "E2E testing:"
- |
# Export map the parameters to the dockerfile env.
export docker-registry-protractor=${RUNNER_IMG}
export docker-registry-client-dist=${CLIENT_IMG}
export docker-registry-server-dist=${SERVER_IMG}

export HOME=/protractor
# Move to the Protractor test project folder
mkdir $HOME
# Get the docker compose file:
cp devops-repo/my-pipeline/templates/e2e/docker-compose.yml $HOME/docker-compose.yml
# Get the tests:
cp client-repo/test/e2e/** $HOME
cd $HOME

# https://github.com/concourse/concourse/issues/324

# Spin up the stack as described in docker-compose:
docker daemon &
docker-compose up

Dockerfile 使用在管道的上一步中构建并上传到私有(private) Docker 注册表的容器。

最佳答案

This repo很好地了解了如何在 docker in concourse 中运行 docker compose - 您最终要做的是使用预先安装了 docker compose 的 docker 镜像,然后加载其他镜像。使用 concourse 预取这些图像,然后在本地缓存它们确实有助于提高性能。

一个技巧是,将 docker compose 文件放在获取的代码存储库中实际上更容易,而不是放在大厅配置中。

缩写的大厅 yml:

  - name: integration
plan:
- aggregate:
- get: code-from-git-resource
params: {depth: 1}
passed: [unit-tests]
trigger: true
- get: redis-docker-image
params: {save: true}
- get: busybox-docker-image
params: {save: true}
- task: Run integration tests
privileged: true
config:
platform: linux
image_resource:
type: docker-image
source:
repository: amidos/dcind
inputs:
- name: code-from-git-resource
- name: redis-docker-image
- name: busybox-docker-image
run:
path: sh
args:
- -exc
- |
source /docker-lib.sh
start_docker

# Strictly speaking, preloading of images is not required.
# However you might want to do it for a couple of reasons:
# - If the image is from a private repository, it is much easier to let concourse pull it,
# and then pass it through to the task.
# - When the image is passed to the task, Concourse can often get the image from its cache.
docker load -i redis-docker-image/image
docker tag "$(cat redis-docker-image/image-id)" "$(cat redis-docker-image/repository):$(cat redis-docker-image/tag)"

docker load -i busybox-docker-image/image
docker tag "$(cat busybox-docker-image/image-id)" "$(cat busybox-docker-image/repository):$(cat busybox-docker-image/tag)"

# Run the tests container and its dependencies.
docker-compose -f code-from-git-resource/example/integration.yml run tests

关于docker - 使用 Concourse 的 docker 资源来获取要在 docker compose 中使用的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40883047/

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