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

430
Vistas
How to add volume mount to running postgreSQL container?

I have a running postgreSQL docker container and need to add a volume mount.

I followed the steps from How can I add a volume to an existing Docker container?, (ran docker commit on the container to save it as an image, and spun up another container based on that image with a named volume mounted in). All the data files from the first container are present in /var/lib/postgres/data of the second container.

However, when I try to query this second postgres database, I cannot see any tables that are in the first container. Been trying to fix this for a few days with no luck, am I missing something here (does mounting a volume obscure the existing data in /var/lib/postres/data)?

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

0

Commit will not work as there is the volume defined in the Dockerfile.

Volumes are useful in many cases, for example, for running database-storage. However, since volumes are not 'part' of a container, it makes containers no longer portable - which seems in direct conflict with the slogan "Build once... Run anywhere.."

docker commit data container with VOLUME

One option that you can try is copying data folder to host from an existing container and then launch the container with mount path.

docker cp my_db_cotainer:/var/lib/postgresql/data  db_data

then start a new container with this path so it will contain the same data as the previous one

docker run -d --name some-postgres -v $PWD/db_data/:/var/lib/postgresql/data postgres

same for mysql

docker cp some-mysql-old:/var/lib/mysql db_backup
docker run --rm --name some-mysql-new -v $PWD/db_backup:/var/lib/mysql  -it mysql
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