So I actually "solved" this issue right before posting this question, but I'll ask it anyway because I'd like to know why what I did works,
I have nginx installed via brew and the docker nginx base image in my local machine.
I have the directory /container/logs/nginx and I'm mounting it to /var/log/nginx that's inside of a docker container using
docker run -d -P -v /container/logs/nginx:/var/log/nginx nginx
I was expecting to see the access and error .log files in the mounted directory. However, nothing was there.
I thought maybe, even though there were no error messages, that there might be a permissions issue with mapping from a directory that resides in my root directory, so I instead mapped it to /Users/jimmygong/containers/logs/nginx , using
docker run -d -P -v /Users/jimmygong/container/logs/nginx:/var/log/nginx nginx
This does work. Could someone walk me through exactly what's occurring here? Do I not have write permissions outside of my home directory (eg /Users/jimmygong)? I'm running Mac OS.
This is because of the automount
script of boot2docker
- I am assuming you are using boot2docker
since you are using brew
and your user dir starts with /Users
. That and the fact you also need to tell virtualbox to expose your shared directory.
Imagine how your volume is shared:
your mac <--X--> boot2docker VM <----> nginx container
\_ /Users is mounted properly, but not other dir.
see:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.