我有一个Dockerfile,语法如下COPY ["Gemfile", "Gemfile.lock", "Procfile", ".env", "/huginn/"]
我使用RUN /bin/bash -l -c "ls -a"
来检查文件科普状态,我发现.env文件没有被复制到映像。
我将.env文件名更改为test.env并使用COPY ["Gemfile", "Gemfile.lock", "Procfile", "test.env", "/huginn/"]
,然后它工作,test.env被复制到映像中。
有没有人知道为什么是?还有什么解决方案可以让docker支持COPY
.env文件名?
5条答案
按热度按时间e7arh2l61#
如果你有
.dockerignore
文件,那么它可能是你添加忽略隐藏文件,如.git
,.vagrant
等。如果
.dockerfile
忽略隐藏文件,那么您可以启用不忽略或更改文件名。有关.dockerignore文件的详细信息
zzzyeukh2#
.dockerignore文件文档中有一条语句:
xesrikrc3#
共享我的dockerfile,它现在可以正常工作
还有一个.
6fe3ivhb4#
我遇到了同样的问题,这里有一个简单的解决方案===〉
复制隐藏文件与确切的目录路径一样:-
示例:- COPY路径/.hidenfile目标路径
nbysray55#
您的COPY语法错误,此语法对Dockerfile中的ENTRYPOINT或CMD有效。
请参阅文档以获取COPY
https://docs.docker.com/engine/reference/builder/#/copy