0

I'm trying to run a python script but before my script I have to do docker run -it --rm psycopg2 python. Inside my script I want to calculate some results and then store them locally in files.

I currenty do all the above by hand. First I run docker run -it --rm psycopg2 python and then I type one by one the python commands to the shell but I still cannot save anything to a file locally.

Any ideas?

  • [-v or --volume](https://docs.docker.com/storage/bind-mounts/): Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious. In the case of bind mounts, the first field is the path to the file or directory on the host machine. The second field is the path where the file or directory is mounted in the container. The third field is optional, and is a comma-separated list of options, such as ro, z, and Z. These options are discussed below. – dani herrera Nov 05 '20 at 13:33
  • This is inherent in using Docker containers, they are meant to be ephemeral. Search for 'persist data Docker' to find how you can share folders between containers and your local file system. – stfwn Nov 05 '20 at 13:33
  • An ordinary Python virtual environment (without Docker) might be easier to use, since it can directly access your host files while having an isolated package install space. – David Maze Nov 05 '20 at 13:46

0 Answers0