I just dockerized an executable that reads from a file and creates a new file in the very directory that file came from.
I want to use Docker in that setup, so that I avoid installing numerous third-party libraries in the production environment.
My problem now: I have file /this/is/a.file
on my underlying (host) file system and my executable is supposed to create /this/is/b.file
.
As far as I see it, the only chance to get this done is by mapping a volume that points to /this/is
and then let the executable know where I mounted it to in the docker, container.
Am I right? Or is there a way that I just pass docker run mydockerizedstuff /this/is/a.file
without using Docker volumes?
You're correct, you need to pass in
/this/is
as a volume and the executable will write to that location.If you want to constrain the thing even more, you can pass
/this/is/b.file
as a volume. You need to create it (simply viatouch
) beforehand, otherwise Docker will consider it a directory and create it as such for you, but you'll know that the thing won't be able to create/this/is/c.file
or any other thing.