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 !

  • @[email protected]OP
    link
    fedilink
    28 months ago

    Thank you !!

    One step closer :-D if I have the python file all ready to go in the directory, it works, but I can’t seem to use my binaries (or the python script) if I compile them in into the image only.

    I have my executables in a “binaries_to_use” folder, is there any way to add them to this local work folder? I tried the thing that worked before:

    COPY binaries_to_use/setup /

    but then

    CMD [“./setup”]

    doesn’t work, I guess it’s no longer a “virtual folder for the image” any more?

    Thanks again, I’m getting less dumb about this :-p

    • @[email protected]
      link
      fedilink
      English
      18 months ago

      I have my executables in a “binaries_to_use” folder, is there any way to add them to this local work folder? I tried the thing that worked before:

      Put them in one of the folders on the $PATH or provide an absolute path to them in your CMD