13

After trying docker cp from here, it still throws a Error: No such container:path:...

enter image description here

What am I doing wrong?

  • The container is running
  • I can run docker exec commands
  • docker cp fails
β.εηοιτ.βε
  • 24,064
  • 11
  • 54
  • 67
ndemasie
  • 439
  • 1
  • 3
  • 13

1 Answers1

19

From the documentation:

The docker cp command assumes container paths are relative to the container’s / (root) directory.

Source: https://docs.docker.com/engine/reference/commandline/cp/#extended-description

This means that, when your docker exec [CONTAINER] ls is affected by the WORKDIR, your docker cp is not.

What you should do from there is to run:

  1. docker exec [CONTAINER] pwd
  2. Use what this yields you in the docker cp command to have a fully qualified path to use in you docker cp command

e.g. from the httpd image:

$ docker run -d --name httpd httpd

$ docker exec httpd pwd
/usr/local/apache2

$ docker exec httpd ls
bin
build
cgi-bin
conf
error
htdocs
icons
include
logs
modules

$ docker cp httpd:/usr/local/apache2/conf .

All this because the httpd image defines a WORKDIR on the folder /usr/local/apache2.

β.εηοιτ.βε
  • 24,064
  • 11
  • 54
  • 67
  • This is the solution. Thank you! I am quite a newbie to docker and documentation isn't all that clear to me yet :) – ndemasie Nov 01 '20 at 15:25
  • as another docker newb I was confused because docker-compose and docker have different names for containers. docker ps to find docker name – Thom Dec 02 '20 at 15:17