简体   繁体   中英

Save a file generated by app running on docker to a given path in the host machine

I have a python app running on a docker container and it generates a pdf file. I want to store the generated pdf file in a given path in the host machine.

I am not sure on how can this be achieved. Any ideas?

Mount a volume in your container mapped to the desired path in your host

docker run -d -v /host/path:/python_app/output your_docker_image

Where /python_app/output is the path inside the container where your app is writing the pdf file.

Note that /host/path should have enough permissions

chmod 777 /host/path

Use volumes to mount directory in a container to host director:

docker run -v /MY/HOST_DIR:/MY/CONTAINER_DIR 

Your pdf file will be stored in /MY/HOST_DIR on host.

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