In the yml files of Docker Compose, the volumes are declared in a section that starts with volumes: line and followed by patterns such
yml
Docker Compose
volumes:
awk '$1=="-"{if (f) print; next} {f=/^[[:space:]]*volumes:/}' file