简体   繁体   中英

Send a file from inside the docker container to outside

docker cp is used to copy files from one container to host but you have to run docker cp from outside the container. My question is, how to do it when I am inside the container using command

docker exec -it container_id /bin/bash

Do we have something like scp here?

I think the easiest way of doing this is to mount part of the host filesystem to the container and just spit out the file to the mount point.

The whole idea of containers is that they're not able to do stuff with the host system unless the docker admin explicitly allows it.

You may also try mounting the docker socket to the container (if it's a Docker-in-Docker container) and docker cp from within the container itself, but the first solution is way cleaner IMHO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM