Repository navigation
Open
Description
- This is a bug report
- This is a feature request
- I searched existing issues before opening this one
Expected behavior
Docker ignores directory which is specified in .dockerignore and proceeds with building an image.
Actual behavior
Docker reports an error: error checking context: 'can't stat '.../DB''.
Steps to reproduce the behavior
docker -v
printf "FROM alpine:latest\n" > Dockerfile
printf "DB\n" > .dockerignore
mkdir DB
sudo chown root:root DB
sudo chmod 700 DB
docker build -t test .
Version 18.03 output:
Docker version 18.03.1-ce, build 9ee9f40
Sending build context to Docker daemon 5.12kB
Step 1/1 : FROM alpine:latest
---> 11cd0b38bc3c
Successfully built 11cd0b38bc3c
Successfully tagged test:latest
Version 18.06 output:
Docker version 18.06.0-ce, build 0ffa825
error checking context: 'can't stat '/REDACTED/DB''.
Output of docker version:
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Wed Jun 20 21:43:51 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Wed Jun 20 21:42:00 2018
OS/Arch: linux/amd64
Experimental: false
Client:
Version: 18.06.0-ce
API version: 1.38
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:09:54 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.0-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:07:56 2018
OS/Arch: linux/amd64
Experimental: false
Output of docker info:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 11
Server Version: 18.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-29-generic
Operating System: Ubuntu 18.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.709GiB
Name: SCharykovPC
ID: DUGK:34M2:G6EY:CK5R:ARHF:ISVB:XKB3:FWCF:5AYK:GK5P:3IBO:TOMS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 11
Server Version: 18.06.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d64c661f1d51c48782c9cec8fda7604785f93587
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-29-generic
Operating System: Ubuntu 18.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.709GiB
Name: SCharykovPC
ID: DUGK:34M2:G6EY:CK5R:ARHF:ISVB:XKB3:FWCF:5AYK:GK5P:3IBO:TOMS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Additional environment details (AWS, VirtualBox, physical, etc.)
Reacted by Michael Endsley, Yang Qian, Chris Dickson, Jean-Francois Labbé, Attila Nagy, Cyan, Oliver Bünting, Daniel Williams, Servin Nissen, Adam and 37 more
Metadata
Metadata
Assignees
Labels
No labels
Activity
catvec commentedon Sep 21, 2018
I am also encountering this issue.
I am developing an application which requires a database for development. I am running a local Postgres instance in a Docker container. I mount this Docker container's data directory on my local file system so that the database is persisted between shutdowns. I have added the Postgres container's data directory to my
.dockerignore.When I try to build my application's Docker image I get the error from the original bug report. Even though I have
.dockerignored the directory Docker still tries tostatit.AngelOnFira commentedon Nov 6, 2018
I'm running into this as well, same situation as @Noah-Huppert . I came up with a fix that works for now, which is storing the Postgres data folder inside of another folder, and
.dockerignoreing that. Janky solution though.catvec commentedon Nov 6, 2018
Thanks @AngelOnFira, that's actually really clever.
Francesco149 commentedon Dec 4, 2018
i'm experiencing the same thing with docker's root directory. I have a dir structure like
the dockerignore contains
and /vault/docker is my docker root dir (runs with
-g /vault/docker)when building i get
error checking context: 'can't stat '/vault/docker''and yeah i can work around this by moving /vault/docker into a nested dir
alekratz commentedon Dec 27, 2018
I am experiencing this issue with this version of Docker:
The "put it in a subdirectory and ignore the subdirectory" workaround works for me.
miend commentedon Feb 5, 2019
I am experiencing this issue on Docker version:
Again with a postgres DB volume included in the .dockerignore, but still statted by Docker. Nesting my
pgdatadirectory inside another directory (data) and addingdata/to the .dockerignore successfully worked around the issue.krizex commentedon Feb 19, 2019
Encountered the same issue on
Docker version 18.09.1, build 4c52b90sweber83 commentedon Mar 8, 2019
Stumbled on this issue, too using docker version:
18.09.2, build 624796bartfeenstra commentedon Apr 30, 2019
I believe I am running into the same problem. Not with a database, but with the containerized application's private file storage.
Partial
docker buildoutput that includes the relevant error:error checking context: 'can't stat '(...)/app/private''.shukriadams commentedon Aug 26, 2019
For me this was caused by running
in a folder with a lot of messy folders that were linked to other containers etc. Fixed by moving Dockerfile to a clean, dedicated build folder of its own.
cpuguy83 commentedon Sep 7, 2019
But what does the dockerfile look like? I cannot repro this.
moznuy commentedon Sep 10, 2019
From the second step of "Steps to reproduce the behavior":
So the example Dockerfile looks like this:
FROM alpine:latestcpuguy83 commentedon Sep 12, 2019
Ok, I think I see why.
The ignore syntax doesn't really do recursive ignores so it tries to stat it to read what's inside.
rupeshtech commentedon Oct 4, 2019
in my case following was root cause and soltuions
Cause:
Solution:
A system restart and the deleting the folder works.
Now not getting error.
jordiclariana commentedon Oct 22, 2019
Still happening:
12 remaining items
Fix various issues breaking the build
denisvmedia commentedon Jan 22, 2021
This happens to me in a rootless installation of docker:
I'm able to build for the first time, but repeating the action fails. It is a headache especially in the case when a user is not allowed to run
sudocommands.Cheaterman commentedon Jan 26, 2021
I don't get it though, this used to work, right? I'm fairly sure I had a setup where the
.dockerignoreworked properly, but now I don't...For reference, it worked here on 19.03.12 and broke in 19.03.13 or 14. Or it's possibly a case of "it works the first time" as some other users reported?
EDIT: My bad, it's not about the docker version. Build succeeds when using
docker-composeand fails when usingdockerdirectly with what I presumed (probably wrongly) was the same command...Fuseteam commentedon Sep 1, 2021
i have this issue with a sshfs mount too it simply ignores dockerignore :/ i'm not using the snap
this workaround still works tho
misc: fix pgdata volume ownership issues
bryangeplant commentedon Mar 4, 2022
Is this fixed? is it stuck? What happened here? The issue is still open.
Change postgres volume mount to fix docker builds
Cheaterman commentedon Mar 6, 2023
Still not fixed, hit this again today ; the behavior changed however - docker-compose is now in line with docker and fails the same way.
build: fix repro builds where host userid != 1000
build: fix repro builds where host userid != 1000
build: fix repro builds where host userid != 1000
Create the subdirectory for PG data, needed for a silly Docker bug
ipepe commentedon Jul 26, 2023
Still relevant and blocker for some situations.
bb-master-docker: Move docker volumes to single common directory
build: fix repro builds where host userid != 1000