Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

428
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda