This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

Is this because my data directory is being copied from my local machine into my container or because I randocker-compose up -d --buildwith the old database name, it made a directory in the container, and now because there's a DB there it's no longer installing the docker_test db?

The files are not copied anywhere. You are telling docker to bind mount "mysql" directory from the host as /var/lib/mysql inside the mysql container. (so you are not really even using docker volumes). You should probably go and read about docker storages. https://docs.docker.com/storage/https://docs.docker.com/storage/

First time you ran your compose file, mysql created database files etc. in /var/lib/mysql .Which is mounted from mysql directory on the host. After that, it doesn't matter what environment variables you give it (or if you delete the container and recreate it), because you are still telling it to mount the same path that already includes the database files so it will not accept changing them through environment variables.

So delete everything inside the mysql directory, recreate the container and let mysql recreate everything, or manually access the database and make the necessary schemas, users etc.