Docker Community Forums

Share and learn in the Docker community.

Can't commit MySQL image

docker

(Nicolasduminil) #1

Hello,

I pulled out a MySQL image (docker.io/mysql) and, once I started the container, I created a new database and I commited this modification with the container filesystem.
But stoping and restarting the container, the new database doesn’t appear and I need to create it again and again. What did I miss here ?
Many thanks in advance,

Nicolas


(Nathan Le Claire) #2

The database is kept in a docker volume (kept out of the standard Docker layers) because writing to the copy-on-write filesystem doesn’t really make sense for persistent data / databases. Those should read and write directly to the backing filesystem. Generally you shouldn’t keep persistent state in images themselves. If you need to seed the database on docker run have a little entrypoint script or sidebar container that connects and does so.