Ignoring .dockerignore



My .dockerignore is being ignored and it’s driving me crazy. My docker file has the following COPY statement

WORKDIR /gg-dash
COPY . /gg-dash

…and after I do a RUN ls -l just to see what got copied.

My .dockerignore file (in root next to Dockerfile) has the following statements:


…but I’m still getting everything copied (including .git) - Am I doing something wrong here?



Hey @chrisallmark this is because .dockerignore files are not supported on the resin build servers. I will raise this item for discussion and update this thread after this.


Cool. Thanks for the update.


I second this request! Would love to see this also on cli build feature (i.e., resin build).


The .dockerignore seems to be ignored for me during resin local push builds, as well. Is that the case?

It’s mentioned in documentation but I keep ending up with explicitly ignored files on the host. .resin-sync.yml and --ignore don’t work either.


Dev Machine:
2018 15" MBP
macOS 10.13.6
node 10.10.0
Docker version 18.03.1-ce, build 9ee9f40
resin cli 7.9.3

Target Machine:
raspi 3 b+
Resin OS 2.15.1+rev1

Ignoring doesn’t seem to work at all, in any situation. PLEASE HELP @CameronDiver !

For example I’m working on a node project for raspi3. Both .gitignore and .dockerignore have a single line for node_modules.

If I have a node_modules directory on my dev machine (which I have to use different dev dependencies during development) and I run any of the following:

  • resin push appName -c
  • sudo resin local push --source . -f
  • resin deploy appName --build

The node_modules from my dev machine gets copied to my raspi3 (I know this because I’m dependent on some packages that need to be of a certain architecture… onoff etc) and my container fails to run with errors.

HOWEVER. If I rm -rf node_modules before I run any of the above commands then things seem to work perfectly. Heretofore ignoring files doesn’t work. Not with gitignore. Not with dockerignore. And the documentation on resin.io talks about using dockerignore multiple times (eg https://docs.resin.io/learn/deploy/build-optimization/#use-dockerignore). This should work!

Edit: I also tried doing an update through git push resin master and that did not heed dockerignore either. I think this wouldn’t be such a big deal if it wasn’t in the docs (a couple times) that dockerignore does something. Maybe for now remove it from the docs?


@chachi @johnslemmer we have recently implemented this here: https://github.com/resin-io/resin-cli/pull/950

We are adding a lot of changes to the build infrastructure, some of them breaking changes (such as the above). For that reason we are collecting them together, and will release a v8 of the CLI soon. If you prefer, you can check out the v8-meta-branch git branch that these changes were merged to, and use them in a beta form.

Note that the ignore files will be respected on resin build, and resin push. For now, resin local push will not respect them, but that support is also coming.

Let me know if you run into any problems using this branch!