Ich benutze Docker-Compose, um meinen Service zu definieren. In Docker gibt es zwei Konzepte für das Docker-Volume. Erstens geht es um bind mount
: Mount auf Host-Speicher.
docker run -d --name web-app -v $Host/location:/container/location -p 80:80 httpd:latest
Zweitens geht es um managed mount
: Abstrakte Speicherung, unabhängig vom Host.
docker run -d --name web-app -v /container/location -p 80:80 httpd:latest
Ich möchte diese Konzepte Docker-Compose zuordnen. Es bedeutet, wie kann ich bind mount
Und managed mount
Definieren, wenn Docker-Compose verwendet wird.
Sie finden diese Docker-Konzepte im Abschnitt volumes
von Docker Compose: https://docs.docker.com/compose/compose-file/#/volumes-volumedriver
Beispiele:
volumes:
# Just specify a path and let the Engine create a volume
- /container/location
# Specify an absolute path mapping
- ./myfolder/location:/container/location
Obwohl ich sehr spät antworte. Aber vielleicht hilft es anderen Menschen in Zukunft. Unten finden Sie die Konfiguration für beide Typen. https://docs.docker.com/compose/compose-file/#volumes
version: "3.2"
services:
web:
image: httpd:latest
volumes:
- type: bind
source: $Host/location
target: /container/location
- type: volume
source: mydata
target: /container/location
volumes:
mydata: