问题描述
我曾经在 .dockerignore
中列出 tests
目录,以便它不会包含在映像中
I used to list the tests
directory in .dockerignore
so that it wouldn't get included in the image, which I used to run a web service.
现在,我正在尝试使用Docker来运行单元测试,在这种情况下,我希望使用<$ c $包括c> tests 目录。
Now I'm trying to use Docker to run my unit tests, and in this case I want the tests
directory included.
我检查了 docker build -h
和发现没有相关的选项。
I've checked docker build -h
and found no option related.
我该怎么做?
推荐答案
Docker 19.03为此提供了一个解决方案。
Docker 19.03 shipped a solution for this.
使用此功能当前需要设置 DOCKER_BUILDKIT = 1
环境变量。该标志可与 docker compose
一起使用,因为,由。
Setting the DOCKER_BUILDKIT=1
environment variable is currently required to use this feature. This flag can be used with docker compose
since 1.25.0-rc3 by also specifying COMPOSE_DOCKER_CLI_BUILD=1
.
另请参见:
- https://github.com/moby/moby/issues/12886#issuecomment-480575928
- https://github.com/moby/moby/issues/12886#issuecomment-518843764
- https://github.com/moby/moby/issues/12886#issuecomment-523706042
这篇关于如何为同一项目中的不同版本指定不同的.dockerignore文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!