12
$ docker cp maven-container_:xxxx.war /home/wissem/Documents/docker-stage/wildfly-configured/target/

Error response from daemon: lstat

/var/lib/docker/aufs/mnt/afbdc7f4ce3165fb2e6c34929841b9fa911de1978887dd5b9b0804e4f624af2d /xxxx.war: no such file or directory

ERROR: Job failed: exit status 1

2
  • You need to copy from a running instance and not an image. So I assume maven-container_ is a name of the container your had launched and not a image. Also use complete path after :, docker cp maven-container_:/path/inside/container/xxxx.war /home/wissem/Documents/docker-stage/wildfly-configured/target/ Commented Aug 14, 2017 at 21:11
  • SOLVED : it was my path : docker cp maven-container_:/opt/maven/targe/xxxx.war .... Commented Aug 14, 2017 at 23:27

5 Answers 5

19

You need to copy from a running instance and not an image. So I assume maven-container_ is a name of the container your had launched and not a image. Also use complete path after :,

docker cp maven-container_:/path/inside/container/xxxx.war /home/wissem/Documents/docker-stage/wildfly-configured/targe‌​t/
Sign up to request clarification or add additional context in comments.

4 Comments

Thsnk. Helped me figure out the problem.
doesn't need to be running
to copy from an image without running it - create a container with a name. docker create my_image_tag --name my_cont_name; docker cp my_cont_name:/path/file /home/...
Thanks, i was trying to copy out after my test container had exited after finishing tests. I guess the test image is not the same as the instance of docker run, which was a fork of the container image that is lost when it's done?
11

I got this error when trying to copy a file under the root folder (seems related to @uthomas's answer).

$ docker cp dreamy_brown:/root/myfile.txt ~
Error: No such container:path: dreamy_brown:/root/myfile.txt

Solution: From within the container I first moved the file to the /tmp folder:

$ mv /root/myfile.txt /tmp

and then I was able to copy it to the host:

$ docker cp dreamy_brown:/tmp/myfile.txt ~

2 Comments

For anyone else in "Solution" step you have to be inside the container first. I was running inside compose: $docker-compose exec CONTAINER_NAME bash. That brought me to /root/ where I could then move/copy files to tmp as explained.
Thanks. Copy file to /tmp/ works fine. But I am not sure why it does not work on the original file in docker container?
6

For me it didn't work because of permissions. The file I was trying to copy was owned by postgres user, while the default user seems to be root.

1 Comment

Weird since root user should have access to everything. I tried the suggestion by @asherbret to first move them to /tmp but that is not helping. Plus, the files I am looking at are owned by root, have permissions -rw-r--r--., and are not links. Unless them being root is the problem because the container's default user in my case is something else... Nope, whoami says root.
0

I couldn't copy because I was using wildcards.

Didn't work:

docker cp af1f3010481a:/tmp/mydir/* .

Worked:

docker cp af1f3010481a:/tmp/mydir/myfile.txt .

Comments

0

For me I found that I just need to restart the mysql container.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.