How to attach volume to a multi container using a yaml file

What is the correct way to attach an existing volume called mkt_data to a container in a yaml file?
The yaml file below gives an error saying:
service “bots” refers to undefined volume mkt_data: invalid compose project

name: my_app
image: image1
container_name: ibeam
- env.list
network_mode: bridge
restart: ‘no’

image: bot
container_name: bot
- type: volume
source: mkt_data
target: /data
- 5000
- 5001

you need to declare volumes in the top-level.
see: Undefined volume with Docker Compose - Stack Overflow

In a YAML file, attach the existing volume mkt_data to a container by defining the volume in the volumes section and specifying the mount path in the container’s volumeMounts section.

Thanks, are there any examples on the net? Easier to see what works.

Thanks, I’ll take a look.