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).
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.
可以用数据卷功能将主机的目录挂载到容器里
Dockerfile 中
ADD
和COPY
命令不能使用绝对路径,只能使用相对路径。这点在官方文档中说的比较清楚https://docs.docker.com/reference/builder/#add 。如果不是非要把文件 build 到 image里,可以通过 run container 的时候通过 -v 参数将 host 文件或目录加载/共享到 container 里。 参考 https://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume
docker 的cp命令可以从容器往外复制,也可以从本机复制的容器。
docker cp more.log e7de404c00bd:/tmp/