"volumes 'type' is a required property" when running docker-compose
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Dreamlands
--
Chapters
00:00 &Quot;Volumes 'Type' Is A Required Property&Quot; When Running Docker-Compose
00:59 Accepted Answer Score 20
01:40 Thank you
--
Full question
https://superuser.com/questions/1390250/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#bash #docker #container #yaml
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Dreamlands
--
Chapters
00:00 &Quot;Volumes 'Type' Is A Required Property&Quot; When Running Docker-Compose
00:59 Accepted Answer Score 20
01:40 Thank you
--
Full question
https://superuser.com/questions/1390250/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#bash #docker #container #yaml
#avk47
ACCEPTED ANSWER
Score 20
The compose file is whitespace sensitive (this is yaml formatting). There are two different volume sections in a compose file, one where the volume is defined at the top level of indentation, and another where the volume is used within a service. You've attempted to define both within the service, and the second set of volumes is defined incorrectly for defining how to use the volume (it needs a target directory there). The following is what you want to try:
version: '3.2'
services:
mydb:
image: postgres
volumes:
- db-data:var/lib/postgres/data
ports:
- "5432:5432"
volumes:
db-data: