Onno Onno - 3 months ago 17
MySQL Question

Why is MariaDB data persistent in my Docker container? I don't have any volumes

I have a Docker container with MariaDB installed. I am not using any volumes.

[vagrant@devops ~]$ sudo docker volume ls
DRIVER VOLUME NAME
[vagrant@devops ~]$


Now something strange is happening. When I do
sudo docker stop
and
sudo docker start
the MariaDB data is still there. I expected this data to be lost.

Btw when I edit some file for example
/etc/hosts
I do see the expected behavior. Changes to this file are lost after restart.

How is it possible that MariaDB data is persistent without volumes? This shouldn't happen right?

Answer

docker stop does not remove a container, neither does docker start create a container.

docker run does create a new container from a image.

docker start starts a container which does exist but has been stopped before ( call it pause/resume if you like ). Thus for start/stop no volumes are required to keep the state persistent.

if you though do docker stop <name> && docker rm <name> and then docker start <name> you get and error, that the container does no longer exist - so now you need docker run <args> youimage