最后活跃于 1712091017

Jigsaw1601 修订了这个 Gist 1712091017. 跳至此修订

1 file changed, 20 insertions

docker-copy-volume.sh(file created)

@@ -0,0 +1,20 @@
1 + #!/bin/bash
2 +
3 + # Check if the required arguments are provided
4 + if [ $# -ne 2 ]; then
5 + echo "Usage: $0 <volume_id> <destination>"
6 + exit 1
7 + fi
8 +
9 + # Assign arguments to variables
10 + volume_id=$1
11 + destination=$2
12 +
13 + # Create a temporary container to mount the volume
14 + container_id=$(docker create -v $volume_id:/source_data --name temp_container busybox)
15 +
16 + # Copy the data from the volume to the destination
17 + docker cp $container_id:/source_data $destination
18 +
19 + # Remove the temporary container
20 + docker rm $container_id
更新 更早