The command docker cp
is used to copy files/folders between a container and the host.
$ docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
# OR
$ docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
Here, -
specified for either SRC_PATH
or DEST_PATH
enables to stream tar archive from STDIN
or to STDOUT
. And SRC_PATH
or DEST_PATH
can be a file or directory.
Options;
--archive
, -a
→ Archive mode — copy all userid or groupid (uid/gid) information--follow-link
, -L
→ Follow the symbol link in SRC_PATH$ docker cp cloudyfox_web:/index.html index.html
$ docker cp ./index.html cloudyfox_web:/index.html
$ docker cp CONTAINER:/var/logs/app.log - | tar x -O | grep "ERROR"
Note: Please note cp
command produces a tar stream.