Home > other >  Docker deployed mysql problem: mysql with tables and data containers, packaged into the mirror after
Docker deployed mysql problem: mysql with tables and data containers, packaged into the mirror after

Time:10-19

Question phenomenon:
Set up table has data in mysql container through the docker commit way to generate images, and then use the mirror create containers, can normal connection, but there is no previous data
Source and scene:
Rookie a docker into the pit, a project using mysql, want to take the inside of the data migration, I use the mysql docker mirror and the back end service, after the container is configured user information, and also built a table, store the data, then I would like to pack the container into a mirror, use the mirror to create the container, docker run - I - p 3306:3306 - t image, the database connection found before built lost
How is this to return a responsibility excuse me

CodePudding user response:

Data in a mysql database default is stored in the/var/lib/mysql directory, and mysql container is normally within the container/var/lib/mysql as a volume mount, when you use the commit command to take containers packed into the mirror, the commit operation does not contain container mounted volume of data changes, so will find data are gone,

I this two days is in the pits on for a long time

CodePudding user response:

Into the container to see the data is in the directory/var/lib/mysql, so if something elegant way to mount the volume data is packaged in together, I can only think of to mount the/var/lib/mysql to Linux locally, then package tucked into the image, the feeling is not very elegant
  • Related