I'm having in Dockerfile
:
ENV DATARATOR_HOME /usr/local/share/datarator
RUN mkdir -p $DATARATOR_HOME
COPY . $DATARATOR_HOME
and .dockerignore
file:
/Gemfile.lock
/coverage
/spec
*.bundle
*.so
*.o
*.a
mkmf.log
*.swp
/.*
/tmp
/log
However, once showing files in the built container, I can see also those that are supposed to be ignored:
/usr/local/share/datarator # ls -lha
total 128
drwxr-xr-x 10 root root 4.0K Mar 29 21:01 .
drwxr-xr-x 4 root root 4.0K Mar 29 21:00 ..
drwxr-xr-x 2 root root 4.0K Mar 29 21:01 .bundle
-rw-rw-r-- 1 root root 24 Mar 29 20:37 .coveralls.yml
-rw-rw-r-- 1 root root 81 Mar 29 20:37 .dockerignore
drwxrwxr-x 8 root root 4.0K Mar 29 20:37 .git
-rw-rw-r-- 1 root root 85 Mar 29 20:37 .gitignore
-rw-rw-r-- 1 root root 1.2K Mar 29 20:37 .travis.yml
-rw-rw-r-- 1 root root 509 Mar 29 20:37 .vimrc
-rw-rw-r-- 1 root root 959 Mar 29 20:37 Dockerfile
-rw-rw-r-- 1 root root 94 Mar 29 20:37 Gemfile
-rw-r--r-- 1 root root 2.7K Mar 29 21:01 Gemfile.lock
-rw-rw-r-- 1 root root 343 Mar 29 20:37 Guardfile
-rw-rw-r-- 1 root root 1.0K Mar 29 20:37 LICENSE.txt
-rw-rw-r-- 1 root root 71 Mar 29 20:37 Procfile
-rw-rw-r-- 1 root root 14.8K Mar 29 20:37 README.md
-rw-rw-r-- 1 root root 198 Mar 29 20:37 Rakefile
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 bin
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 config
-rw-rw-r-- 1 root root 97 Mar 29 20:37 config.ru
-rw-r--r-- 1 root root 16.0K Mar 29 21:01 datarator-0.0.1.gem
-rw-rw-r-- 1 root root 1.7K Mar 29 20:37 datarator.gemspec
drwxrwxr-x 4 root root 4.0K Mar 29 20:37 lib
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 log
drwxrwxr-x 3 root root 4.0K Mar 29 20:37 spec
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 tmp
How can I achieve having all those mentioned in the .dockerignore
file ignored?
dockerignore file is on the root directory of your context, it will ignore it if it is somewhere in the subfolder.
The . dockerignore file is very similar to the . gitignore file in that it allows you to specify a list of files or directories that Docker is to ignore during the build process. This can come in really handy in certain instances.
The documentation says that yes it can. You can even use the . dockerignore file to exclude the Dockerfile and . dockerignore files.
The .dockerignore
rules follow the filepath/#Match
.
Try (for testing) Gemfile.lock
instead of /Gemfile.lock
.
And check that the eol (end of line) characters are unix-style, not Windows style in your .dockerignore
file.
Apparently, (docker 1.10, March 2016) using rule starting with /
like /xxx
( or /.*
) is not well supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With