Я видел определения томов Docker в docker-compose.yml
файлах, например:
-v /path/on/host/modules:/var/www/html/modules
Я заметил, что официальный образ Drupal, их docker-compose.yml
файл использует анонимные тома.
Обратите внимание на комментарии:
volumes:
- /var/www/html/modules
- /var/www/html/profiles
- /var/www/html/themes
# this takes advantage of the feature in Docker that a new anonymous
# volume (which is what we're creating here) will be initialized with the
# existing content of the image at the same location
- /var/www/html/sites
Есть ли способ связать анонимный том с путем на хост-компьютере после запуска контейнера? Если нет, то какой смысл в анонимных томах?
Полный пример docker-compose.yml:
version: '3.1'
services:
drupal:
image: drupal:8.2-apache
ports:
- 8080:80
volumes:
- /var/www/html/modules
- /var/www/html/profiles
- /var/www/html/themes
# this takes advantage of the feature in Docker that a new anonymous
# volume (which is what we're creating here) will be initialized with the
# existing content of the image at the same location
- /var/www/html/sites
restart: always
postgres:
image: postgres:9.6
environment:
POSTGRES_PASSWORD: example
restart: always