Docker build ignoring .dockerignore

Expected behavior

Running docker build . on a folder with a .dockerignore file should respect settings in this file

Actual behavior

COPY . /var/app command in Dockerfile is copying everything, completely ignoring the .dockerignore file (no pun intended)

Information

Dockerfile

FROM r-base

# Create app folder
RUN mkdir -p /var/app
WORKDIR /var/app

# Copy app files into app folder
COPY . /var/app

.dockerignore

.git
.ipynb_checkpoints/*
/notebooks/*
/unused/*
Dockerfile
.DS_Store
.gitignore
README.md
env.*
/devops/*

# To prevent storing dev/temporary container data
*.csv
/tmp/*

Output of ls -la inside container (including files/folders that should have been ignored):

root@4600245e7ea0:/var/app# ls -la
total 18344
drwxr-xr-x 21 root root   714 May 11 18:25 .
drwxr-xr-x 24 root root  4096 May 12 03:26 ..
drwxr-xr-x 11 root root   374 May 12 03:04 devops
-rw-r--r--  1 root root   816 Apr 25 14:36 Dockerfile
-rw-r--r--  1 root root   170 May 12 03:25 .dockerignore
-rw-r--r--  1 root root 13391 May  4 18:23 DTP_algo_python_script.py
-rw-r--r--  1 root root   610 Apr 28 17:31 DTP_load_Rdata.py
-rw-r--r--  1 root root  3708 May  4 17:44 DTP_mirt_model.R
-rw-r--r--  1 root root   641 Apr 28 17:31 DTP_save_Rdata.py
-rw-r--r--  1 root root  2759 May  4 17:44 DTP_scorecard_update.R
-rw-r--r--  1 root root   940 Apr 28 18:14 env.list
-rw-r--r--  1 root root   739 May  3 16:15 env.template
drwxr-xr-x 16 root root   544 May  4 18:28 .git
-rw-r--r--  1 root root   141 May  3 16:15 .gitignore
drwxr-xr-x 11 root root   374 May  3 16:15 notebooks
-rw-r--r--  1 root root  3058 May  4 17:44 push_results_to_elastic.py
-rw-r--r--  1 root root  4681 May  4 17:44 README.md
-rw-r--r--  1 root root   516 Apr 25 14:06 requirements.txt
drwxr-xr-x  6 root root   204 May  3 16:15 scripts
drwxr-xr-x  5 root root   170 Apr 29 18:20 tmp
-rw-r--r--  1 root root  2129 Apr 29 18:27 update_last_started_at.py

docker version

Client:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Wed Apr 27 00:34:20 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   8b63c77
 Built:        Fri Apr 29 14:13:26 2016
 OS/Arch:      linux/amd64

OSX 10.11.4 (15E65)

This can be completely ignored. Issue was with my .dockerignore file that didn’t have proper configuration for the directories I wanted to exclude. Fixing those got everything working again.

.git
.ipynb_checkpoints
notebooks
unused
Dockerfile
.DS_Store
.gitignore
README.md
env.*
devops

# To prevent storing dev/temporary container data
*.csv
tmp