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

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

问题描述

我有一个 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文件名?

解决方案

如果你有 .dockerignore 文件,那么你可能会添加它来忽略像 .git 这样的隐藏文件, .vagrant

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

有关 .dockerignore 文件的更多信息

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

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.

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.

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

解决方案

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

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

For more info about .dockerignore file

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

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