我想了解為什么我們volumes
在 docker compose 檔案中有內部服務,而volumes
在同一個檔案中有外部服務?我們不能只用一個嗎?
下面是使用 postgres 資料庫構建的 durpal 內容管理系統:
version: '2'
services:
durpal:
image: durpal
ports:
- '8080:80'
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD = mypasswd
volumes:
- drupal-modules:
- drupal-profiles:
- drupal-sites:
- drupal-themes:
uj5u.com熱心網友回復:
請參閱官方檔案:使用volumes
頂級元素定義要在其中使用的命名卷docker-compose.yml
。
另一方面,使用volumes
service 屬性,您可以指定在該容器中安裝卷的位置,參考頂級元素中定義的命名卷。
您(可以)將卷的定義留空的原因是,為省略的詳細資訊分配的默認值在大多數情況下已經是您想要的。因此,僅指定卷的名稱就足以讓它們使用默認配置創建。查看volumes
頂級元素檔案以了解可用的其他配置。
要了解有關卷的更多資訊,請參閱檔案中的此頁面。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/505086.html