Reputation: 71
To replace the volumes_from:
directive from version 2 (for helpyio), I tried this, but something went wrong.
version: "3"
services:
frontend:
...
volumes:
- myVolume:/var/www:ro
backend:
...
volumes:
- myVolume:/var/www
volumes:
myVolume:
driver: local
driver_opts:
type: none
device: "/my/local/absolute/path/"
o: bind
I have errors like
ERROR: for frontend: Cannot create container for service frontend: failed to mount local volume: mount /my/local/absolute/path/:/var/www, flags: 0x1000: no such file or directory
I also tried some variant in volumes:
options but without success. And last thing, I don't want to create manually this local directory.
I am sure to miss something, but can't see what... Has anyone a solution for this use case?
Many thanks
Upvotes: 7
Views: 13627
Reputation: 49
sudo mkdir /static
docker-compose.yml
version: "3.9"
services:
web:
volumes:
- "static_volume:/app/media"
volumes:
static_volume:
driver: local
driver_opts:
type: volume
o: bind
device: /static
Upvotes: -1
Reputation: 311606
There's no reason to make your docker-compose.yml
that complicated. You can simply do this:
version: "3"
services:
frontend:
...
volumes:
- /my/local/absolute/path/:/var/www:ro
backend:
...
volumes:
- /my/local/absolute/path/:/var/www
Upvotes: 3