这是我想做的:
- 进行 docker-compose 构建
- 运行 docker-compose $COMPOSE_ARGS run --rm task1
- 运行 docker-compose $COMPOSE_ARGS run --rm task2
- 运行 docker-compose $COMPOSE_ARGS run --rm combine-both-task2
- 运行 docker-compose $COMPOSE_ARGS run --rm selenium-test
同时还需要一个像这样的 docker-compose.yml 文件:
task1:
build: ./task1
volumes_from:
- task1_output
command: ./task1.sh
task1_output:
image: alpine:3.3
volumes:
- /root/app/dist
command: /bin/sh
# essentially I want to copy task1 output into task2 because they each use different images and use different tech stacks...
task2:
build: ../task2
volumes_from:
- task2_output
- task1_output:ro
command: /bin/bash -cx "mkdir -p task1 && cp -R /root/app/dist/* ."
现在所有需要的文件都在task2容器中了...那我该如何启动一个Web服务器并暴露一个端口,以便使用task2中的内容?
我卡在这里了...我该如何在我的combine-tasks/Dockerfile中访问task2_output中的内容?
combine-both-task2:
build: ../combine-tasks
volumes_from:
- task2_output
docker run
期间存在,而不是在docker build
期间存在。因此,RUN ls hello.txt
未连接到共享以进行读取,而RUN echo "hello" > hello.txt
仅在本地写入第一个映像。我将添加完整的Python Dockerfile,以便您可以复制我的示例的所有部分。 - Jett Jones