I have a MariaDB container, to handle my database.
Here is my problem, I execute :
docker-compose exec mariadb mysql -u root
to enter MariaDB container and create a test database, then exit the container, and shut it down through command :
docker-compose down
After that, I start back all my containers through command
docker-compose up
go back inside the MariaDB container to see if the database I added persisted but, I found out it did not. I thought I had correctly parameterized MariaDB volumes through this line in my docker-compose :
- '/bitnami/mariadb/:/var/lib/mysql'
Here is my complete docker-compose.yml file :
version: '2'
services:
myapp:
image: 'bitnami/symfony:1'
ports:
- '8000:8000'
volumes:
- '.:/app'
environment:
- SYMFONY_PROJECT_NAME=backend
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- MARIADB_USER=monty
- MARIADB_PASSWORD=monty
- MARIADB_DATABASE=test
container_name: symfony_container
depends_on:
- mariadb
mariadb:
image: 'bitnami/mariadb:10.3'
ports:
- '3306:3306'
volumes:
- '/bitnami/mariadb/:/var/lib/mysql'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_DATABASE=test
- MARIADB_PORT_NUMBER=3306
- MARIADB_ROOT_USER=root
- MARIADB_USER=monty
- MARIADB_PASSWORD=monty
container_name: mariadb
If anyone have any leads for me I'll be greatfull.
You've got the volume line reversed.
- '/bitnami/mariadb/:/var/lib/mysql'
That mounts the host directory /bitnami/mariadb/
inside the container at /var/lib/mysql
. Instead you want:
- '/var/lib/mysql/:/bitnami/mariadb/'
The image documentation specifies the target directory here: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#persisting-your-database
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.