blakek blakek - 1 year ago 83
MySQL Question

Is MariaDB data lost after Docker setting change?

I've setup a basic MariaDB instance running in Docker - basically from starting the container using the Kitematic UI, changing the settings, and letting it run.

Today, I wanted to make a backup, so I used Kitematic to change the port so I could access it from a machine to make automated backups. After changing the port in Kitematic, it seems to have started a fresh MariaDB container (i.e. all my data seems to be removed).

Is that the expected behavior? And, more importantly, is there any way to recover the seemingly missing data, or has it been completely removed?

Also, if the data is actually removed, what is the preferred way to change settings—such as the exposed ports—without losing all changes?

docker commit


  • running docker 1.12.0 beta for OS X

  • docker -ps a
    shows the database status as "Up for X minutes" when the original had been up for several days

Thanks in advance!


It looks like the recommended procedure to retain data (without creating a volume or similar) is to:

  1. commit changes (e.g.
    docker commit <containerid> <name/tag>

  2. take the container offline

  3. update settings such as exposed port or whatever else

  4. run the image with committed changes

...taken from this answer.

Answer Source

Yes, this is expected behavior. If you want your data to be persistant you should mount volume from host (via --volume option for docker run) or from another container and store your database files at this volume.

docker run --volume /path/on/your/host/machine:/var/lib/mysql mariadb

Losing changes are actually core feature of containers so it can not be omitted. This way you can be sure that between every docker run you get fresh environment without any changes. If you want your changes to be permanent you should do them in your image's Dockerfile, not in container itself.

For more information please visit official documentation: