ubuntu 未使用Docker COPY复制隐藏文件.env

6qfn3psc  于 2022-11-28  发布在  Docker
关注(0)|答案(5)|浏览(187)

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

e7arh2l6

e7arh2l61#

如果你有.dockerignore文件,那么它可能是你添加忽略隐藏文件,如.git.vagrant等。
如果.dockerfile忽略隐藏文件,那么您可以启用不忽略或更改文件名。
有关.dockerignore文件的详细信息

zzzyeukh

zzzyeukh2#

.dockerignore文件文档中有一条语句:

Note: For historical reasons, the pattern . is ignored.

xesrikrc

xesrikrc3#

共享我的dockerfile,它现在可以正常工作

FROM ruby:2.3

MAINTAINER Tomato <tsaohucn@gmail.com>

ENV DEBIAN_FRONTEND noninteractive
ENV LANG C.UTF-8
ENV RAILS_VERSION 5.0.1

# install rails && bundler
RUN gem install rails --version "$RAILS_VERSION"

WORKDIR /huginn

# copy huginn config file
COPY ["Gemfile", "Gemfile.lock", "Procfile", ".env", "/huginn/"]
COPY lib/gemfile_helper.rb /huginn/lib/
COPY vendor/gems /huginn/vendor/gems

# run bundle install
RUN bundle install

# copy huginn
COPY . /huginn/
RUN ls -a

还有一个.

.git
tmp
log
doc
spec
media
.openshift
.bundle
vendor/bundle
db/*.sqlite3
public/system/*
coverage
.travis.yml
build_docker_image.sh
# Copied from .gitignore
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
!/tmp/.gitkeep
**.orig
rerun.txt
pickle-email-*.html
.idea/
.DS_Store
deployment/tmp
deployment/cookbooks
.vagrant
.*un~
.ruby-gemset
.ruby-version
manifest.yml
config/unicorn.rb
db/schema.rb
6fe3ivhb

6fe3ivhb4#

我遇到了同样的问题,这里有一个简单的解决方案===〉
复制隐藏文件与确切的目录路径一样:-
示例:- COPY路径/.hidenfile目标路径

nbysray5

nbysray55#

您的COPY语法错误,此语法对Dockerfile中的ENTRYPOINT或CMD有效。
请参阅文档以获取COPY
https://docs.docker.com/engine/reference/builder/#/copy

相关问题