Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.dockerignore "last-line" precedence not respected #3886

Closed
cjerdonek opened this issue Aug 28, 2016 · 3 comments · Fixed by docker/docker-py#1914
Closed

.dockerignore "last-line" precedence not respected #3886

cjerdonek opened this issue Aug 28, 2016 · 3 comments · Fixed by docker/docker-py#1914

Comments

@cjerdonek
Copy link

Docker compose doesn't seem to respect the "last-line" precedence of .dockerignore files. This is described here in the .dockerignore docs.

For example, even the simple example provided in the doc section above doesn't seem to work when using Docker compose:

 *.md
!README*.md
README-secret.md

The file README-secret.md gets included -- not excluded.

I'm using the following:

docker-compose version 1.8.0, build 94f7016
Docker version 1.11.1, build 5604cbe
Mac OS X 10.11.6
@reflectivecode
Copy link

I'm seeing the same issue in 1.14.0

$ docker-compose version
docker-compose version 1.14.0, build c7bdf9e
docker-py version: 2.3.0
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

$ docker version
Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:31:53 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.06.0-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:51:55 2017
 OS/Arch:      linux/amd64
 Experimental: true

@frankiethekneeman
Copy link

I am also getting this issue. A complete reproduction:


jarvis[/mnt/dv01/test/]
Wed Sep 20, 02:16:14|frank[2121]$ docker version
Client:
 Version:      17.06.2-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 20:00:17 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.2-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 19:59:11 2017
 OS/Arch:      linux/amd64
 Experimental: false

jarvis[/mnt/dv01/test/]
Wed Sep 20, 02:16:16|frank[2122]$ tree -a
.
├── docker-compose.yml
├── Dockerfile.frontend
├── .dockerignore
└── frontend
    ├── file
    ├── nested
    │   └── node_modules
    │       └── another_bad_file
    └── node_modules
        └── bad_file

4 directories, 6 files

jarvis[/mnt/dv01/test/]
Wed Sep 20, 02:16:18|frank[2123]$ cat docker-compose.yml
version: "3.0"
services: 
  frontend:
    build: 
      context: .
      dockerfile: Dockerfile.frontend

jarvis[/mnt/dv01/test/]
Wed Sep 20, 02:16:20|frank[2124]$ cat Dockerfile.frontend
FROM ubuntu:xenial

RUN apt-get update && apt-get install -y --no-install-recommends \
    tree \
  && rm -rf /var/lib/apt/lists/*

WORKDIR workspace

COPY frontend/ .

CMD tree

jarvis[/mnt/dv01/test/]
Wed Sep 20, 02:16:23|frank[2125]$ cat .dockerignore
*
!frontend
**/node_modules

jarvis[/mnt/dv01/test/]
Wed Sep 20, 02:16:25|frank[2126]$ docker build . -f Dockerfile.frontend -t test && docker run --rm test
Sending build context to Docker daemon  4.608kB
Step 1/5 : FROM ubuntu:xenial
xenial: Pulling from library/ubuntu
9fb6c798fa41: Pull complete 
3b61febd4aef: Pull complete 
9d99b9777eb0: Pull complete 
d010c8cf75d7: Pull complete 
7fac07fb303e: Pull complete 
Digest: sha256:60f835698ea19e8d9d3a59e68fb96fb35bc43e745941cb2ea9eaf4ba3029ed8a
Status: Downloaded newer image for ubuntu:xenial
 ---> 2d696327ab2e
Step 2/5 : RUN apt-get update && apt-get install -y --no-install-recommends     tree   && rm -rf /var/lib/apt/lists/*
 ---> Running in 10a2ed46e772
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [49.8 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [450 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.8 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [211 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [2928 B]
Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [219 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [816 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.5 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [686 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [17.5 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5176 B]
Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6192 B]
Fetched 24.4 MB in 2s (8462 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  tree
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 40.6 kB of archives.
After this operation, 138 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe amd64 tree amd64 1.7.0-3 [40.6 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 40.6 kB in 0s (172 kB/s)
Selecting previously unselected package tree.
(Reading database ... 4768 files and directories currently installed.)
Preparing to unpack .../tree_1.7.0-3_amd64.deb ...
Unpacking tree (1.7.0-3) ...
Setting up tree (1.7.0-3) ...
 ---> f150eb8cd85a
Removing intermediate container 10a2ed46e772
Step 3/5 : WORKDIR workspace
 ---> 4a35277b912f
Removing intermediate container 1e4c93e792e3
Step 4/5 : COPY frontend/ .
 ---> e729a796a5d5
Removing intermediate container f0c4e7d359db
Step 5/5 : CMD tree
 ---> Running in 002318ce6ef3
 ---> d44868390256
Removing intermediate container 002318ce6ef3
Successfully built d44868390256
Successfully tagged test:latest
.
|-- file
`-- nested

1 directory, 1 file

jarvis[/mnt/dv01/test/]
Wed Sep 20, 02:16:39|frank[2127]$ docker-compose up --force-recreate --build
Building frontend
Step 1/5 : FROM ubuntu:xenial
 ---> 2d696327ab2e
Step 2/5 : RUN apt-get update && apt-get install -y --no-install-recommends     tree   && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> f150eb8cd85a
Step 3/5 : WORKDIR workspace
 ---> Using cache
 ---> 4a35277b912f
Step 4/5 : COPY frontend/ .
 ---> 7b6741ab4f84
Removing intermediate container bfc82368d8d7
Step 5/5 : CMD tree
 ---> Running in e6d7130e5f1b
 ---> 51df147dff7c
Removing intermediate container e6d7130e5f1b
Successfully built 51df147dff7c
Successfully tagged test_frontend:latest
Creating test_frontend_1 ... 
Creating test_frontend_1 ... done
Attaching to test_frontend_1
frontend_1  | .
frontend_1  | |-- file
frontend_1  | |-- nested
frontend_1  | |   `-- node_modules
frontend_1  | |       `-- another_bad_file
frontend_1  | `-- node_modules
frontend_1  |     `-- bad_file
frontend_1  | 
frontend_1  | 3 directories, 3 files
test_frontend_1 exited with code 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@cjerdonek @mefyl @shin- @frankiethekneeman @reflectivecode and others