Service "nginx" refers to undefined volume www-data: invalid compose project

Hi everone, when I run “docker compose -f docker-compose.yml up -d”
I receve this message: service “nginx” refers to undefined volume www-data: invalid compose project

My compose:
####################################
version: “3”
services:
nginx:
image: nginx:latest
container_name: nginx
volumes:
- www-data:/usr/share/nginx/html
ports:
- 80:80
volumes:
www-data:
####################################

If I use the volume in the format /var/data/www-data:/usr/share/nginx/html the container works, any suggestions?

Works for me when indented properly. Please format your code so we can see it properly:
```yml

your code here

```

1 Like

It really was yaml formatting, thank you very much Deanayalon.

1 Like