Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Data is lost in Mysql docker container after comminting it to a new image?

I pulled a mysql base image from docker hub and run a container from that image and created a database and some tables in that container, and committed the changes to a new image. But when i run a container of my new image, there are no databases that i have created. How to achieve this? I don't want to use mounted volumes because i want to link this container with another container of my application so that it can inset and update into db .

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I don't know which image you're using but I believe every Dockerfile of official mysql images has following command:

VOLUME /var/lib/mysql

which means all mysql data goes to volume. From docker volume docs they specially mentioned that:

> Changes to a data volume will not be included when you update an image.

And this is the root cause you loss your data in newly started container.

For your question:

How to achieve this?

You can use either mounted volumes, or create a data volume container, then run mysql container with option --volumes-from. The former links contain step-by-step guide of how to do it.

I don't want to use mounted volumes because i want to link this container with another container of my application so that it can inset and update into db

I don't know what other concerns you have about mounted volumes, but as far as I can tell, using mounted volumes does not prevent you to link containers.

Hope this helps you.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda