It's a very rough explanation because I don't understand much yet, You can use the named volume by writing the docker-compose.yml file as shown below.
docer-compose.yml
version: '3'
services:
web:
build: .
...
volumes:
- .:/myapp
- gem_data:/usr/local/bundle
#here
...
volumes:
gem_data:
#This is important.
- gem_data:/usr/local/bundle
This is the named path.
At the bottom of the above code,
volumes:
gem_data:
Without this
ERROR: Named volume "gem_data:/usr/local/bundle" is used in service "gem_data:" but no declaration was found in the volumes section.
I get an error and it seems that I can not specify it unless I use a relative path or an absolute path.
It seems that it is basically better to use a named path than to use a relative path.
reference
Mounting MySQL data on Docker to the host directory with Volume will be troublesome around permissions https://qiita.com/ysd_marrrr/items/e8a50c43cff87951385c
Recommended Posts