隐藏文件 .env 未使用 Docker COPY 复制 [英] Hidden file .env not copied using Docker COPY

查看:27
本文介绍了隐藏文件 .env 未使用 Docker COPY 复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Dockerfile,并且有这样的语法 COPY ["Gemfile", "Gemfile.lock", "Procfile", ".env", "/huginn/"]

I have a Dockerfile and there is a syntax like this COPY ["Gemfile", "Gemfile.lock", "Procfile", ".env", "/huginn/"]

我使用 RUN/bin/bash -l -c "ls -a" 来检查文件处理状态,我发现 .env 文件没有被复制到图像中.

I use RUN /bin/bash -l -c "ls -a" to check file cope status, I find .env file doen't be copied to the image.

我将 .env 文件名更改为 test.env 并使用 COPY ["Gemfile", "Gemfile.lock", "Procfile", "test.env", "/huginn/"],然后它起作用了,test.env被复制到图像中.

I change the .env file name to test.env and use COPY ["Gemfile", "Gemfile.lock", "Procfile", "test.env", "/huginn/"], then it work, test.env is copied to the image.

有人知道为什么吗?而任何解决方案都可以让docker支持COPY.env文件名?

Anyone know why is? And any solution can let docker support COPY .env file name?

推荐答案

如果你有 .dockerignore 文件,那么可能是你添加了忽略隐藏文件,如 .git, .vagrant

If you have .dockerignore file then it might be you added to ignore hidden files like .git, .vagrant etc.

如果 .dockerfile 忽略隐藏文件,那么您可以启用不忽略或更改文件名.

If .dockerfile ignoring hidden files then either you can enable to not ignore or change file name.

有关 .dockerignore 文件的更多信息

这篇关于隐藏文件 .env 未使用 Docker COPY 复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆