Search code examples
dockerdockerfiledocker-machine

Copy a folder from Docker to host


I'm using the following cmd to copy a folder from docker to host.

 docker cp nostalgic_brattain:/Documents ~/Documents/MyFolder

Unfortunately, it says Error: No such container:path: nostalgic_brattain:/Documents

what am I missing?


Solution

  • It means you are trying to copy for a path inside the container which does not exit. You should exec inside your docker container using docker exec -it nostalgic_brattain /bin/<shell your container uses (sh or bash)> Once inside the container, navigate to the exact location, run the pwd command, and use that in your 'docker cp' command.

    You might also be able to find out the location by observing the Dockerfile.