I am running two docker containers.
I want to persist my database, therefore I use volumes in my docker-compose file. Still I lose data whenever I restart the containers (docker-compose down and up).
What I am missing? (I am on ubuntu 20.04)
services:
adminer:
image: adminer
restart: always
ports:
- 8080:8080
db:
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'example' # TODO: Change this
volumes:
- "./config/my.conf:/etc/mysql/conf.d/config-file.cnf"
- "./data:/var/lib/mysql:rw"
Use docker-compose stop
instead of docker-compose down
.
From the documentation :
docker-compose down: Stops containers and removes containers, networks, volumes , and images created by up.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.