Inhaltsverzeichnis

Docker Copy files

Container

Good Examples

Official Documentation

The first example copies a file from the /tmp directory on the host machine into the Grafana install directory in the grafana container:

docker cp /tmp/config.ini grafana:/usr/share/grafana/conf/

To copy files from the grafana container to the /tmp directory on the host machine, we just switch the order of the parameters:

docker cp grafana:/usr/share/grafana/conf/defaults.ini /tmp

We can also copy an entire directory instead of single files. This example copies the entire conf directory from the grafana container to the /tmp directory on the host machine:

docker cp grafana:/usr/share/grafana/conf /tmp

Volume

You can't copy directly into a Volume, thus a temporary container needs to be started.

docker container create --name temp -v my-jenkins-volume:/data busybox
docker cp . temp:/data
docker rm temp

Source from stackoverflow