'How create mount point in docker-compose.yml
I want create mount point for file path /my/host/dir. I create volumes in docker-compose.yml
volumes:
data-db: /my/host/dir
and i try use db-data
postgres:
image: postgres:14.2
volumes:
- db-data:/var/lib/postgresql/data
but i get ERROR: In file './docker-compose.yml', volume 'db-data' must be a mapping not a string.
My docker-compose.yml:
version: '3.9'
services:
postgres:
image: postgres:14.2
volumes:
- db-data:/var/lib/postgresql/data
volumes:
db-data: /home/db/
Solution 1:[1]
version: '3.9'
services:
postgres:
image: postgres:14.2
volumes:
- db-data:/var/lib/postgresql/data
volumes:
db-data:
Notice the deleted path under the root volumes key. The root "volumes" only specifies that it exists, not the path where. For more info and list of available configuration options check the docs: https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference
To elaborate more what the error means... You can specify the volume like this:
volumes:
db-data:
external: true
name: my-db-data
So docker expects the "thing" following the : after db-data to be a key/value mapping. But you provided string /home/db instead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tomáš Fejfar |
