After trying docker cp
from here, it still throws a Error: No such container:path:...
What am I doing wrong?
docker exec
commandsdocker cp
failsdocker cp does not create parent directories for DEST_PATH if they do not exist.
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|- docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH Copy files/folders between a container and the local filesystem Use '-' as the source to read a tar archive from stdin and extract it to a directory destination in a container.
Dockerfile Command to Keep the Container Running Method 1: You can use the -t (pseudo-tty) docker parameter to keep the container running. Method 2: You can run the container directly passing the tail command via arguments as shown below. Method 3: Another method is to execute a sleep command to infinity.
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:
docker exec [CONTAINER] pwd
docker cp
command to have a fully qualified path to use in you docker cp
commande.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With