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

我只是一个虾纸丫 提交于 2019-12-23 10:58:11

问题


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?


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/38507929/save-a-file-generated-by-app-running-on-docker-to-a-given-path-in-the-host-machi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!