copy files from a docker container to the host machine using cmd
docker cp <containerId>:/file/path/within/container /host/path/target
copy files from a docker container to the host machine using cmd
docker cp <containerId>:/file/path/within/container /host/path/target
copy file from host to docker container
docker cp foo.txt mycontainer:/foo.txt
copy file to docker container
docker cp foo.txt mycontainer:/foo.txt
docker cp volume
Usage
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
To copy data from the volume to the host, use a temporary container that has the volume mounted.
CID=$(docker run -d -v hello:/hello busybox true)
docker cp $CID:/hello ./
To copy a directory from the host to volume
cd local_dir
docker cp . $CID:/hello/
Then clean up the temporary container.
docker rm $CID
copy file to docker conatiner using docker dockerfile
COPY foo.txt /data/foo.txt
# where foo.txt is the relative path on host
# and /data/foo.txt is the absolute path in the image
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us