In docker compose files we can have volumes with the path to local folders. Mac and windows of course have different user home directories. I am distributing the compose to people different OS. What is the best way to reference a users home folder so we dont have to change all the volume mounts every time?
volumes:
- ~/.ssh:~/.ssh (mac/linux)
- C:/Users/myuser/.ssh:~/.ssh (windows)
Is there any way to define properties based on OS (similar to maven)? Something like this:
properties:
- home_folder: OS == windows? '%HOMEPATH%' : '~'
volumes:
- ${home_folder}/.ssh:~/.ssh
CodePudding user response:
Even though Windows uses %...%
for environment variables, docker-compose.yml
recognize $HOME
notation.
You just need to run :
SET HOME=%HOMEPATH%
before running docker-compose up