2017-02-09 113 views
2

我有一个Dockerfile并没有这样的COPY ["Gemfile", "Gemfile.lock", "Procfile", ".env", "/huginn/"]搬运工COPY .ENV文件失败

语法我用RUN /bin/bash -l -c "ls -a"检查文件应付状态,我觉得.ENV文件doen't被复制到图像。

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

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

+0

一个'。 env'文件应该被默认复制,ls是否在相同的目录下运行? 'ls -a/huginn'? – Matt

回答

2

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

如果.dockerfile忽略隐藏文件,那么要么你可以启用到不能忽视或更改文件名。

For more info about .dockerignore file

+0

如果该文件被忽略,该命令将会报错'lstat .env:no such file or directory' – Matt

+0

you right,there is'.dockerignore' file added to ignore hidden files'.env',所以我不能拷贝.env文件,谢谢你的帮助。 – Tsao

0

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

FROM ruby:2.3 

MAINTAINER Tomato <[email protected]> 

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 

而且还有一个.dockerignore:

.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