Docker Community Forums

Share and learn in the Docker community.

Docker Holding Old MySQL database

I’m a Docker novice so maybe this is obvious but I’ve searched around and cannot understand why this is not working.

We’ve created a MySQL / PHP / Apache / PHPMyAdmin image with docker-compose.

When loading it up we have it so that it automatically loads some databases that are in a particular directory. The databases are .sql files. Now I’ve updated one of the .sql files to have another table in one of our databases. I run docker-compose build --no-cache to try to recreate the image and then docker-compose up, but when I look in PHPMyAdmin the database is the old database without the newly added table to the .sql file.

I’m using Docker locally for testing so I always want to get a fresh copy of that database, never save any cache or what-have-you.

  1. Why is docker not using the updated .sql file when I tell it to docker-compose build --no-cache.
  2. How can I force docker to always use the new .sql file.

I don’t know what types of examples of files you need from me to help. If you ask I’ll supply you with what I can.

Is this just a wish, or is it currently always empty when you want it to be empty?

A wild guess would be that you’re using some volume to persist the data, and that the image only loads initial data when that volume is empty. But that’s really just a wild guess. All we can say is that it’s not something that Docker magically does for you; it’s really the specific image you’re using that does this for you. We need many more details about that to be able to help.