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
services:
ibeam:
image: image1
container_name: ibeam
env_file:
- env.list
ports:
- 127.0.0.1:5000:5000
- 127.0.0.1:5001:5001
network_mode: bridge
restart: ‘no’

bots:
image: bot
container_name: bot
volumes:
- type: volume
source: mkt_data
target: /data
ports:
- 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.