In docker compose I use volumes_from
to load database container data from another container.
mssql-server-linux:
image: mssql-server-linux:2017-latest
depends_on:
- mssql-server-linux-data
volumes_from:
- mssql-server-linux-data
mssql-server-linux-data:
image: mssql-server-linux-data-keva:latest
entrypoint: /bin/sh
volumes:
- /var/opt/mssql
As a result, the database container uses the following volume to store it's data
$ docker volume ls
DRIVER VOLUME NAME
local e0368e9ae230de6578bb18a3a70823d93ecc4acab7905f96380aff4689024c25
I would like to backup and restore database changes with new named image and volume. How do I do this?
EDIT
I tried to back up the volume in tar with no luck either
$ docker run --rm --volumes-from emma_mssql-server-linux_1 -v /c/temp:/backup ubuntu tar cvf /backup/backup.tar /var/opt/mssql
tar: Cannot connect to C: resolve failed
I am not sure this is the root cause for your failure - but have you tried to perform the rename and backup in separate steps?
Remove the old volume
docker volume rm <old-volume-name>
Create a new volume with the name you want to have
docker volume create --name <new-volume-name>
Backup the newly created volume
docker run --rm --volumes-from <container-name> -v $(pwd):/backup busybox tar cvf /backup/<volume-name>.tar /<volume-path>
please share if this resolves it for you.
Please Note: the assumption is that the volume is local on your system - otherwise, it might be a permissions issue and in that case, you may want to create a local copy of the volume before you back it up:
docker cp <container-name>:/<volume-path>/<volume-name>.tar <local-directory>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.