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.
There is a statement in .dockerignore file documentation:
Note: For historical reasons, the pattern . is ignored.
share my dockerfile, it can work correctly now
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
And there is 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