Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

568
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!