docker compose and volumes code example
Example 1: volumes docker compose
version: "2.4"
services:
web:
image: nginx:alpine
ports:
- "80:80"
volumes:
- type: volume
source: mydata
target: /data
volume:
nocopy: true
- type: bind
source: ./static
target: /opt/app/static
networks:
webnet:
volumes:
mydata:
Example 2: docker mount volume
docker run -v /host/directory:/container/directory -other -options image_name command_to_run
Example 3: docker compose volumes
/host/path:/container/path