Development Tools Introduction to Docker Fundamentals of Docker Building Blocks of Docker

How can I download an output of a Python file inside a container to my host machine's dedicated folder?

I have a Python file that 1. Scrapes data of a web page 2. Formats the data into a pandas data-frame 3. downloads the data as an xls file in the folder C:/Sid. I have this Python script inside a container but when I run the container I cannot see a file created as Sid.xls in C:/Sid. I tried the following command docker run - v C:/Sid/: /EIA imagename but its not working.

1 Answer

adrian miranda
adrian miranda
13,191 Points

This is a somewhat difficult question, which can be solved in a variety of ways. The first, which I think you understand already, is that we do not usually want to store out output in a container, because it is likely to go away and be lost when the container is shut down. The usual solution is to have the program actually store the data somewhere else, or move it somewhere else after creating it. A very simple example might be to have your program, when it is done creating an output file, then have it use ftp to an ftp server somewhere. (in python you can use ftplib). Or you might send the output to a web server that permits uploading files. Or connect to a database server and send the data as you retrieve it. All of these will require some work, and creating some place to send the data.