How to make volume on a specific path

It’s really difficult to understand what you are doing. You speak about named volumes but show commands that create a bind mount. So let’s start with something simple. If you create a named volume with such a compose file, does it work or do you get an error?

---
version: "3"
services:
  web:
    image: httpd
    ports:
      - "8080:80"
    volumes:
      - mydata:/data

volumes:
  mydata: