Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 897
DarcliGht Avatar asked Jul 21 '16 15:07

DarcliGht


2 Answers

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
like image 161
Camilo Silva Avatar answered Nov 09 '22 20:11

Camilo Silva


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.

like image 41
atv Avatar answered Nov 09 '22 20:11

atv