Hidden file .env not copied using Docker COPY

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


share my dockerfile, it can work correctly now

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

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

There is a statement in .dockerignore file documentation:

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