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

578
Vistas
Docker volume backup error: Tar: MYCONTAINER_VOLUME: Cannot stat: No such file or directory

I'm trying to backup my volume as described here in the docker documentation: https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes

I'm running the command with the path to the volume:

docker run --rm --volumes-from MYCONTAINER -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /var/lib/docker/volumes/MYCONTAINER_VOLUME

... and also trying with just the name of my volume

docker run --rm --volumes-from MYCONTAINER -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar MYCONTAINER_VOLUME

but no matter what I get an error like: tar: MYCONTAINER_VOLUME: Cannot stat: No such file or directory

This volume was created and linked to the container with docker-compose and its using a local driver for the volume.

When I run docker volume ls I get:

DRIVER              VOLUME NAME

local               MYCONTAINER_VOLUME

Can someone please tell me what i'm doing wrong with this?

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

0

I figured out what the issue was -

The last part of the command should be the path of the volume mounted in the CONTAINER, not the path of the volume on the HOST.

So basically, the formula for this command should be:

docker run --rm --volumes-from MYCONTAINER -v $(pwd):/backup ubuntu tar cvf /backup/MY_BACKUP.tar /PATH/INSIDE/CONTAINER/TO/VOLUME/data

... and this will create MY_BACKUP.tar in the current directory of the HOST.

also, make sure to STOP the container before archiving the volume if its something like postgres like in my case.

Then, to restore the volume if you're using docker-compose (since I had trouble with this too because the documentation isn't specific to preexisting containers / volumes created this way)

1) STOP the container

2) Make sure MY_BACKUP.tar is in the root project directory of the HOST

3) run

docker run --rm --volumes-from MYCONTAINER -v $(pwd):/backup ubuntu bash -c "cd / && tar xvf /backup/MY_BACKUP.tar

4) restart container

Hope this helps someone and I'm certainly open to any ideas to streamline this.

over 4 years ago · Santiago Trujillo Denunciar

0

The documentation assume your container does have a volume associated to your container.
Meaning: your container was started with a volume.
Example:

$ docker run -d \
  --name devtest \
  --mount source=myvol2,target=/app \
  nginx:latest

Check at the very least if you do have volumes created with:

docker volume ls
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