2

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?

Notes:

  • 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!

UPDATE:

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.

Community
  • 1
  • 1
blakek
  • 157
  • 1
  • 8

2 Answers2

2

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: https://docs.docker.com/engine/tutorials/dockervolumes/.

Mateusz Moneta
  • 1,500
  • 1
  • 10
  • 7
  • So, is it safe to say that changing a setting in Kitematic removes the current container, updates the settings, and starts a new container instance? – blakek Aug 13 '16 at 19:31
  • Yes, because it needs to call `docker run` command with different set of arguments. – Mateusz Moneta Aug 13 '16 at 19:37
0

it looks like you dont mount container volume into certain path. You can read about volumes and storing data into container here

you need run container with volume option

$ docker run --name some-mariadb -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:tag

where /my/own/datadir is directory on host machine

Bukharov Sergey
  • 9,767
  • 5
  • 39
  • 54