-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image
Description
I need to save my database from a docker mysql container so other team members can also work on it. Until now we were using this, which worked just fine:
volumes:
- ./db/:/var/lib/mysql/
However the /db folder was really messy, because the /mysql folder contains all the mysql files, not just the database. So I tried to save only the database folder:
volumes:
- ./db/:/var/lib/mysql/database/
But unfortunately i keep getting this error:
[ERROR] --initialize specified but the data directory has files in it. Aborting.
[ERROR] Aborting
However despite what the error says, the /db folder is empty (no hidden files either), so I have no idea what the error actually is.
I have also tried other subdirectories inside /mysql and got the same result. When I revert the changes back to
- ./db/:/var/lib/mysql/
the error goes away.
Full docker-compose.yml:
mysql:
image: mysql:${MYSQL_VERSION:-latest}
restart: always
ports:
- "3306:3306"
volumes:
- ./db/:/var/lib/mysql/${DB_NAME}
networks:
- backend
environment:
MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
MYSQL_DATABASE: "${DB_NAME}"
MYSQL_USER: "${DB_USERNAME}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
container_name: ${PROJECT_PREFIX}_mysql
Metadata
Metadata
Assignees
Labels
questionUsability question, not directly related to an error with the imageUsability question, not directly related to an error with the image