1
我有一个Makefile文件,看起来像这样:运行搬运工集成测试容器而开发的容器运行
dev:
docker-compose up -d --build
test:
DOCKER_ENV="-test" docker-compose up -d --build
// run some integration tests on the containers then
// shut them down (and let ephemeral database disappear)
DOCKER_ENV="-test" docker-compose down -v
我的搬运工,撰写看起来是这样的:
services:
foo:
container_name: foo${DOCKER_ENV}
image: foo:latest
bar:
container_name: bar${DOCKER_ENV}
image: bar:latest
当我尝试运行make dev
然后make test
后者导致用新名称(“-test”)重建dev容器,而不是创建一整套单独的容器 - 这正是我想要的。
如何让开发环境保持运行并定期启动测试环境? (我们将在某个时候做这个CI,但我希望开发人员能够在本地运行所有测试。)
您也可以设置,而不是使用'-p'了'COMPOSE_PROJECT_NAME'环境变量。 – dnephin