Docker: where is docker volume located for this compose file

Viewed 55515

I was setting up some materials for a trainning, when I came around this sample compose file:

https://github.com/dockersamples/example-voting-app/blob/master/docker-compose.yml

and I couldn't find out how this volume is mounted, on lines 48 and 49 of the file:

volumes:
  db-data:

Can someone explain me where is this volume on the host? Couldn't find it and I wouldn't like to keep any postgresql data dangling around after the containers are gone. Similar thing happens to the networks:

networks:
  front-tier:
  back-tier:

Why docker compose accepts empty network definitions like this?

2 Answers

first method

you have to see your volume list :

docker volume ls

then run this command :

sudo docker inspect <volume-name> | grep Mountpoint | awk '{ print $2 }'

second method

you can use this method :

first run docker ps to get your container id then run this :

docker inspect --format="{{.Mounts}}" $containerID

We will get volume path.

Related