The ADD 和 COPY command in Dockerfile cannot use absolute paths, only relative paths. This is stated clearly in the official documentation https://docs.docker.com/reference/builder/#add.
Multiple resource may be specified but if they are files or directories then they must be relative to the source directory that is being built (the context of the build).
If you don’t have to build the files into the image, you can use the -v parameter when running the container to load/share the host file or directory into the container. Reference https://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume
Docker’s cp command can copy out of the container or copy the container from the local machine.
docker cp more.log e7de404c00bd:/tmp/
docker help cp
Usage: docker cp [OPTIONS] CONTAINER:PATH LOCALPATH|-
docker cp [OPTIONS] LOCALPATH|- CONTAINER:PATH
Copy files/folders between a container and your host.
Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.
You can use the data volume function to mount the host’s directory into the container
The
ADD
和COPY
command in Dockerfile cannot use absolute paths, only relative paths. This is stated clearly in the official documentation https://docs.docker.com/reference/builder/#add.If you don’t have to build the files into the image, you can use the -v parameter when running the container to load/share the host file or directory into the container. Reference https://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume
Docker’s cp command can copy out of the container or copy the container from the local machine.
docker cp more.log e7de404c00bd:/tmp/