Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount Volume To User's Home Directory In Docker Container

I want to mount a volume to the the user's home directory inside my Docker container. Inside my docker-compose.yml file I have the following Volumes property specified

volumes:
  - ./conf:$HOME/conf

I would expect this to mount the volume to /root/conf but that doesn't appear to happen. Does Docker/Docker Compose not support environment variable substitution in volume paths? Is there a way I can mount the volume to the user's home directory without having to know that the home directory is /root inside the container?

like image 432
Ryan Baxter Avatar asked Dec 08 '15 16:12

Ryan Baxter


1 Answers

As @Michael mentions in the comments I can use the USER command to ensure that a specific user is used when running the app in the container. This will allow me to mount the volume to that users home directory and guarantee that the correct files are in place for my app.

like image 163
Ryan Baxter Avatar answered Nov 06 '22 02:11

Ryan Baxter