How to customize the location of the global volume in docker-compose?

problem description

give an example

version: "2"

services:
  portainer:
    image: portainer/portainer
    command: -H unix:///var/run/docker.sock
    restart: always
    ports:
      - 9000:9000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

volumes:
  portainer_data:

the default volume location called portainer_data is docker managed (/ var/lib/docker/volumes/portainer_data/_data), so I want to customize a location?

the environmental background of the problems and what methods you have tried

I changed it to,

volumes:
  portainer_data:/my_data

this is wrong. Start the error

Sep.08,2021

- ./portainer_data:/data

begins with . / , that is, the directory where docker-compose.yml is located


upstairs positive solutions can refer to the Laravel dock project


is it impossible to customize?
actually means that you do not want to modify the name references in the above configuration, because if there are too many directory references in yml and it is not convenient to modify them, you want to modify the following global volumes, directly but do not want to directly use the volumes directory of docker. You want to customize it to the current directory.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3cdaf-58c6f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3cdaf-58c6f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?