moby: COPY failed: stat /var/lib/docker/tmp/docker-builder918577595/...
Description
I have a Dockerfile that has the line:
COPY MyAgSourceAPI/conf/php/testsql.php /var/www/
But it causes the error:
COPY failed: stat /var/lib/docker/tmp/docker-builder918577595/MyAgSourceAPI/conf/php/testsql.php: no such file or directory
Steps to reproduce the issue:
- Create a Dockerfile
- docker build -t rkevinburton/myagsourceapi .
Describe the results you received:
COPY failed: stat /var/lib/docker/tmp/docker-builder918577595/MyAgSourceAPI/conf/php/testsql.php: no such file or directory
Describe the results you expected:
I would expect the file to be copied.
Additional information you deem important (e.g. issue happens only occasionally): I have two lines previous to this one:
COPY MyAgsourceAPI/conf/apache/conf.d/myagsource.conf /etc/apache2/conf.d/myagsource.conf COPY MyAgsourceAPI/conf/apache/sites-available/default.conf /etc/apache2/sites-available/default.conf
They copy a single file and both runs without error.
This seems similiar to issues raised on for-mac and for-linux repositories but the solution (correct .dockerignore) does not seem applicable since this file does not exist.
Output of docker version
:
PS C:\Users\rburton\code> docker version
Client:
Version: 17.06.2-ce
API version: 1.30
Go version: go1.8.3
Git commit: cec0b72
Built: Tue Sep 5 19:57:19 2017
OS/Arch: windows/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:19 2017
OS/Arch: linux/amd64
Experimental: true
Output of docker info
:
PS C:\Users\rburton\code> docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 5
Server Version: 17.06.2-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 ipvlan 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: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.41-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: moby
ID: 4ZGZ:VUUY:PSMN:56QB:GSTL:FAYH:J326:YZW3:ZQ5U:63UZ:TIIT:QSTR
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 16
Goroutines: 26
System Time: 2017-09-26T13:26:23.281243Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details (AWS, VirtualBox, physical, etc.):
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 38 (6 by maintainers)
Links to this issue
Commits related to this issue
- fixing issue with docker path: https://github.com/moby/moby/issues/34986 — committed to NicolePell/multi-docker by NicolePell 6 years ago
Check .dockerignore
You probably trying to copy files that are in .dockerignore.
This happened to me when trying to run the docker file from a different directory.
I had the
COPY failed: stat /var/lib/docker/tmp/docker-builder929708051/XXXX: no such file or directory
and managed to resolve this by specifying the docker file.Running
docker build . -f docker/development/Dockerfile
worked.But running
Running
docker build docker/development/Dockerfile` caused this issue.-f
or--file
to specify the name and location of theDockerfile
.It found it strange at first because when i had the
Dockerfile
in the apps root directory it worked fine. This will help if you want to manage your environment docker files a little better.Running
docker build docker/development/Dockerfile
will usedocker/development/Dockerfile
as its build-context; any file referenced from the Dockerfile will need to be inside that path. Whereasdocker build . -f docker/development/Dockerfile
uses.
(first argument) as build context, and loads the Dockerfile fromdocker/development/Dockerfile
as if it was located at the root of the build-context (.
)Always check .dockerignore. I got a project from a third party and it included ‘*’. No wonder i couldn’t copy anything from the context. Thanks @comm1x for pointing it out.
thanks to pointing out the context issue @AshtonHylton-awin and @thaJeztah – that was the answer for me. For those of you using
docker-compose.yml
this type of block will do the equivalent of thedocker build
commands referenced above:COPY only able copy it’s subfolder .
Same problem. The funniest moment - everything was fine few iterations before. Looks like it got broken after
COPY . /some_internal_path
[it was the last successful try during this container development] (built via docker-compose with changed context)I don’t know how to reproduce it, to be frankly. It’s broken now and I cannot find a solution to get it back to work at all.
Does the file
MyAgSourceAPI/conf/php/testsql.php
exist in the path where you’re starting the build from? If you think it’s a bug, can you provide the exact steps to reproduce? Keep in mind that we don’t have access to your build environment, so cannot reproduce the steps you’ve written so far (i.e., we don’t have access to your Dockerfile, or the files you’re using in your Dockerfile.I had the same problem on CentOS 7. It seems it’s related to either filename or filename length.
I had the problem with the filename: node-v6.11.0-linux-x64.tar.xz It worked with the filename: node.tar.xz
It was the same file, I just renamed it.
This might help find the bug.
Following working for me perfectly. I faced this issue, I was not able to copy zeppelin [1GB] directory into docker conatiner. and getting issue “COPY failed: stat /var/lib/docker/tmp/docker-builder977188321/zeppelin-0.7.2-bin-all: no such file or directory”
Does MyAgSourceAPI/conf/php/testsql.php exists in you current dir? All resources must exist in docker build PATH, see below:
Usage: docker build [OPTIONS] PATH | URL | -
Reading through this issue, I don’t think there’s a bug at hand here, so I’ll go ahead and close.
If you do think there’s still a bug after reading through this issue, please open a new ticket with the exact steps to reproduce.
@ahmedbokhari7 if you set the
context:
in your compose-file, both should work; see https://docs.docker.com/compose/compose-file/#contextin your case, context should probably be set to
context: ./src/
dockerignore
is the fix!! thanks@frostyandy2k 's answer solved the problem