THE PROBLEM
I'm developping an ai training app. The app uses docker and some folders are shared (mounted). Absolute paths inside and outside docker differ, and I need to create symlinks that work on both.
PATHS
app /opt/shared/app
host: /opt/<client>/app/ai/training/<uuid>/models
docker /workspace/tlt-experiments/training/<uuid>/models
DESCRIPTION
When I execute a training program (inside docker) it will generate in the directory files
called model.epoch0.tlt, model.epoch1.tlt, ... model.epoch<n>.tlt
If I cd
into host dir or docker dir and execute ln -s model.epoch<n>.tlt model.tlt
, I have a link that's valid inside the docker container and in the host machine
But if I execute from the app a command to generate the links, I need to use absolute routing
ln -s /opt/<client>/app/ai/training/<uuid>/models/model.epoch<n>.tlt /opt/<client>/app/ai/training/<uuid>/models/model.tlt
, which works for the host but is an invalid link pointing to nothing if I execute anything inside the container.
Is there an elegant way to create the link (hopefully not using cd-ln-cd
)?
BONUS
The command I currently use to create the link is the following. It helps me get the last epoch (n)
ls -t <host>/models/ | head -1 | xargs -I @ ln -s <host>/models/@ <host>/models/model.tlt
ADITIONAL INFO
This part of the app's code is written in c, but for the links I'm executing unix commands as parsed strings on system(str) calls.