Hello all!
Can you mount any folder a docker image is running in?
So for example, if I have a python script creating a file “./hello.txt”, it would be written in the folder where I launch “docker-compose up” ?
I have figured out how to write the hello.txt to a subfolder like /data/ (by mapping an image-local folder to /data/), but I’d like to use like ./ for the image itself instead. So that the folder I’m launching the docker-compose in on my PC is mapped to ./ in the image, if that makes more sense.
So this works (in the compose.yml):
volumes:
- ./:/data
but the script must write to “./data/hello.txt”
This doesn’t work:
volumes:
- ./:./
It pops an error: mount path must be absolute
Any idea if this is even possible?
Cheers and thanks !
Even if
./:./
worked you want to be explicit with your container directories..
refers to the current directory and that will change based on what you define as your working directory or whatever the base image uses as a working directory. In other words, it’s kind of brittle.