简体   繁体   中英

Locate files written by a python script in a container that is not running anymore

I have a python script that is dumping a pandas dataframe into a file using:

dataframe.to_csv(file.csv)

After executing the docker container using:

Sudo docker-compose up freqtrade...(and the rest of the command)

I can't locate the file.csv and my cwd is freqtrade/ but can't access the filesystem in the container.

Also tried to save the file to a path in the ubuntu file system but got the following error:

FileNotFoundError: [Errno 2] No such file or directory: '/home/kato/freqtrade/'

If the container has been stopped and has not been removed you should still find it using docker ps with -a :

docker ps -a

If you found the container ID, you can then copy files from its filesystem without starting it using docker cp :

docker cp CONTAINER_ID:absolute/path/to/file ./host/target/path

Another solution to avoid doing this in the future, you could run your container with a bind mount (a directory from your machine would be mapped to a directory inside the container):

docker run -v "$(pwd)"/relative/host_dir:/absolute/container_dir my_image

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