When using compose for development I have my app mounted inside /var/www/html with this:
volumes:
- ./app:/var/www/html
My local copy needs all the images that are in the production website, that are quite a lot so I don't want to store them in my tiny ssd but in a big extenal disk.
So my images are located in my /media/storage/bigdisk/images.
it is possible to mount this location inside the already mounted /var/www/html?
This way doesn't seem to work:
volumes:
- ./app:/var/www/html
- /media/storage/bigdisk/images:/var/www/html/images
This should work normally, the only downside of this solution is that docker will create additional directory in ./app/images
- so it can mount images volume.
For this directory tree:
- app
--- index.php
- docker-compose.yml
- media
--- picture.png
And docker-compose.yml
:
version: '2'
services:
app:
image: ubuntu
volumes:
- ./app:/var/www/html
- ./media:/var/www/html/images
You get:
$ docker-compose run --rm app find /var/www/html
/var/www/html
/var/www/html/index.php
/var/www/html/images
/var/www/html/images/picture.png
This works even when ./app/images
directory is present locally with some content. If it not exists then docker creates empty directory there with root:root
persmission (if container runs as root).
Tested on Docker version 1.12.6
and docker-compose version 1.8.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With