Commit a mysql docker image does not embed a new database -


if create database in mysql container , commit new image. new image not persit database. here scenario

docker run --name some-mysql -e mysql_root_password=my-secret-pw -d mysql docker exec -it some-mysql bash root@e756b3aa719b:/# mysql -uroot -pmy-secret-pw   mysql> show databases; +--------------------+ | database           | +--------------------+ | information_schema | | mysql              | | performance_schema | | sys                | +--------------------+ 4 rows in set (0.00 sec)  mysql> create database michael;  mysql> show databases;          +--------------------+ | database           | +--------------------+ | information_schema | | michael            | | mysql              | | performance_schema | | sys                | +--------------------+ 5 rows in set (0.00 sec)  mysql> exit bye root@e756b3aa719b:/# exit exit 

then commit container image

docker commit 486932c6d7e7 bdd/myproj:1.0 

if create container image database not here

docker run --name newbdd -e  mysql_root_password=my-secret-pw -d mybdd/myproj:1.0 docker exec -it newbdd bash root@004f86506ebf:/# mysql -uroot -pmy-secret-pw mysql> show databases; +--------------------+ | database           | +--------------------+ | information_schema | | mysql              | | performance_schema | | sys                | +--------------------+ 4 rows in set (0.01 sec) 

what's weird mysql client kept history of command "create database michael" server not keep database michael.

i don't understand why.

working intended. data inside container not typically best practice. mysql base image specifies data directory volume not persist.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -