Skip to content

Back up and restore a volume

Select an icon to see what it is.

Step 1 of 6

Start a helper container with two mounts

A volume is just a directory, but the clean way to reach it is another container. The helper mounts the volume at /data and a host directory at /backup. --rm sets AutoRemove so dockerd deletes the helper when it exits.

$ docker run --rm -v appdata:/data -v /srv/backup:/backup alpine tar czf /backup/appdata.tgz -C /data .
PrevNext

POST /v1.45/containers/create

{
"Image": "alpine"
"Cmd": [
"tar"
"czf"
"/backup/appdata.tgz"
"-C"
"/data"
"."
]
"HostConfig": {
"AutoRemove": true
"Binds": [
"appdata:/data"
"/srv/backup:/backup"
]
}
}