Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

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.