How safe is it to store your database in /var/lib/docker/volumes/?

Viewed 114

At the moment my configuration for MySQL database is as follows:

db:
  image: mysql:5.7.22
  restart: unless-stopped
  ports:
    - "3307:3306"
  environment:
    MYSQL_DATABASE: ${DB_DATABASE}
    MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
  volumes:
    - dbdata:/var/lib/mysql/
    - ./mysql/my.cnf:/etc/mysql/my.cnf

volumes:
  dbdata:

Basically my database is stored in /var/lib/docker/volumes/. But how safe is it? Is it fine for production? It seems that docker-compose down (https://docs.docker.com/compose/reference/down/) should remove the database even though it doesn't in my case. But still, it seems slightly dangerous. What are the alternatives? Create folder manually and link the volume to the manually created folder? But in that case every other developer in the team will have to create that folder.

0 Answers
Related