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 documentation claims /bla entry will ignore directory named "bla" in root, but it doesn't #36660

Closed
ghost opened this issue Mar 21, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 21, 2018

Description

.dockerignore documentation https://docs.docker.com/engine/reference/builder/#dockerignore-file claims /bla entry will ignore directory named "bla" in root, but when I actually tested this, only bla will work as an entry, and /bla won't. Since I believe this is inconsistent with a .gitignore, I wonder if this is a docker bug? (If it isn't a docker bug, then I suggest it should be fixed in the documentation.)

Steps to reproduce the issue:

  1. Create a new folder, inside add "Dockerfile" and "bla" folder and ".dockerignore" file
  2. Put "/bla" into .dockerignore as a new line (without quotes)
  3. Build the Dockerfile

Describe the results you received:
"bla" is uploaded to docker daemon, despite "/bla" entry in ".dockerignore" file

Describe the results you expected:
"bla" is not uploaded to docker daemon, because of "/bla" entry in ".dockerignore" file. Alternatively, the docs shouldn't suggest that this works (which they do now, at least as far as my reading comprehension goes, of the /foo/bar example entry that is mentioned)

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:         1.13.1
 API version:     1.26
 Package version: docker-1.13.1-44.git584d391.fc27.x86_64
 Go version:      go1.9.1
 Git commit:      caba767-unsupported
 Built:           Thu Nov 23 21:17:26 2017
 OS/Arch:         linux/amd64

Server:
 Version:         1.13.1
 API version:     1.26 (minimum version 1.12)
 Package version: docker-1.13.1-44.git584d391.fc27.x86_64
 Go version:      go1.9.1
 Git commit:      caba767-unsupported
 Built:           Thu Nov 23 21:17:26 2017
 OS/Arch:         linux/amd64
 Experimental:    false

Output of docker info:

Containers: 26
 Running: 1
 Paused: 0
 Stopped: 25
Images: 615
Server Version: 1.13.1
Storage Driver: devicemapper
 Pool Name: docker-253:1-704589-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 7.63 GB
 Data Space Total: 107.4 GB
 Data Space Available: 24.61 GB
 Metadata Space Used: 21.66 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.126 GB
 Thin Pool Minimum Free Space: 10.74 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.144 (2017-10-06)
Logging Driver: journald
Cgroup Driver: systemd
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Authorization: rhel-push-plugin
Swarm: inactive
Runtimes: oci runc
Default Runtime: oci
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: caba7670d38dc7cddb0c19bcd97cc27fdd65a789 (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: caba7670d38dc7cddb0c19bcd97cc27fdd65a789-dirty (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  WARNING: You're not using the default seccomp profile
  Profile: /etc/docker/seccomp.json
 selinux
Kernel Version: 4.15.9-300.fc27.x86_64
Operating System: Fedora 27 (Workstation Edition)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 12
Total Memory: 15.65 GiB
Name: falcon
ID: NKWR:ZVET:EPGZ:CT3X:BVQH:XY34:4TBN:5PXO:LNQI:T3NB:K44I:WCL7
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure), registry.fedoraproject.org (secure), registry.access.redhat.com (secure), docker.io (secure)

Additional environment details (AWS, VirtualBox, physical, etc.):
tested on a physical dev machine (zen / AMD64, runs fedora 27)

@thaJeztah
Copy link
Member

Looks like you're running an unsupported Red Hat fork of Docker, not the official packages;

 Package version: docker-1.13.1-44.git584d391.fc27.x86_64
 Go version:      go1.9.1
 Git commit:      caba767-unsupported

Also note that Docker 1.13 has reached end of life in May of last year, and has not been maintained since.

Can you try installing a current version of the official package? https://docs.docker.com/install/linux/docker-ce/fedora/

I tried on a current version of Docker, and am not able to reproduce:

mkdir repro-36660 && cd repro-36660

mkdir bla
echo '/bla' > .dockerignore

cat > Dockerfile -<<EOF
FROM busybox
RUN mkdir /copied/
COPY . /copied/
RUN ls -la /copied/
EOF

docker build --no-cache .

Which shows:

Sending build context to Docker daemon  3.072kB
Step 1/4 : FROM busybox
 ---> f6e427c148a7
Step 2/4 : RUN mkdir /copied/
 ---> Running in 5d6e0120fe63
Removing intermediate container 5d6e0120fe63
 ---> cb5349747106
Step 3/4 : COPY . /copied/
 ---> 367453e2c2bf
Step 4/4 : RUN ls -la /copied/
 ---> Running in 3989ba0cc064
total 16
drwxr-xr-x    1 root     root          4096 Mar 22 00:55 .
drwxr-xr-x    1 root     root          4096 Mar 22 00:55 ..
-rw-r--r--    1 root     root             5 Mar 22 00:48 .dockerignore
-rw-r--r--    1 root     root            68 Mar 22 00:48 Dockerfile
Removing intermediate container 3989ba0cc064
 ---> 97947ba13f22
Successfully built 97947ba13f22

I'm closing this issue, because this does not appear to be reproducible on a current version of Docker, but feel free to continue the conversation

@ghost
Copy link
Author

ghost commented Mar 22, 2018

Ok, I tested your neat reproduction script and indeed it gives a wrong result here. I filed a ticket with Red Hat about this: https://bugzilla.redhat.com/show_bug.cgi?id=1559274

@runcom
Copy link
Member

runcom commented Mar 22, 2018

This has been fixed by 1cde87c#diff-c87a8ca60f0891b79d192fa86f019916

We're updating the package in Fedora with that commit

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

No branches or pull requests

3 participants