Docker compose - share volume Nginx
If you are using Docker Machine on Windows
, docker has limited access to your Windows filesystem. By default Docker Machine tries to auto-share your C:\Users
(Windows) directory.
So the folder .../Dev/docker/nginx-www/nginx/html/
must be located somewhere under C:\Users
directory in the host.
All other paths come from your virtual machine’s filesystem, so if you want to make some other host folder available for sharing, you need to do additional work. In the case of VirtualBox you need to make the host folder available as a shared folder in VirtualBox.
You have to set a command to copy your nginx.conf
into the nginx container:
FROM nginxCOPY nginx.conf /etc/nginx/nginx.conf`
Creat a dir name it nginx and put the Dockerfile
& nginx.conf
there, then you have to set a build:
web: image: nginx:latest build :./nginx/volumes: - /d/Dev/docker/nginx-www/nginx/html/:/usr/share/nginx/html/ ports: - "80:80"
Then build your containers with : sudo docker-compose build