Docker(九):Docker容器卷插件

时间:2021-10-03 14:51:41

1、Convoy

  1.1 安装

    [root@MediaServer tmp]# tar xvf convoy.tar.gz
    convoy/
    convoy/convoy-pdata_tools
    convoy/convoy
    convoy/SHA1SUMS
    [root@MediaServer tmp]# cp convoy/convoy convoy/convoy-pdata_tools /usr/local/bin/
    [root@MediaServer tmp]# mkdir -p /etc/docker/plugins
    [root@MediaServer tmp]# echo "unix:///var/run/convoy/convoy.sock" > /etc/docker/plugins/convoy.spec

  1.2 启动

    [root@MediaServer tmp]# convoy daemon --drivers vfs --driver-opts vfs.path=/data

  1.3 启动容器使用Convoy插件

    注意:docker版本要在1.10+以上,volTest是卷名字,

    [root@MediaServer ~]# docker run -ti -v volTest:/test --volume-driver=convoy busybox sh

  1.4 Convoy操作

    [root@MediaServer ~]# convoy create volumetest

    volumetest

    [root@MediaServer ~]# convoy list
    {
      "volumetest": {
      "Name": "volumetest",
      "Driver": "vfs",
      "MountPoint": "",
      "CreatedTime": "Tue Oct 10 21:03:43 +0800 2017",
      "DriverInfo": {
        "Driver": "vfs",
        "MountPoint": "",
        "Path": "/data/volumetest",
        "PrepareForVM": "false",
        "Size": "0",
        "VolumeCreatedAt": "Tue Oct 10 21:03:43 +0800 2017",
        "VolumeName": "volumetest"
      },
      "Snapshots": {}
      }
    }
    [root@MediaServer ~]# convoy delete volumetest

    [root@MediaServer ~]# convoy list
    {}

    创建快照:

      [root@MediaServer ~]# convoy snapshot create volumetest --name snap1voll

      snap1voll

    备份:

      [root@MediaServer ~]# convoy backup create snap1voll --dest vfs:///opt/convoy

    恢复:

      convoy create res1 --backup vfs:///opt/convoy?backup=backup-0677c4e992f94223\u0026volume=volumetest

    查看备份:    

      {
        "vfs:///opt/convoy/?backup=backup-0677c4e992f94223\u0026volume=volumetest": {
          "BackupName": "backup-0677c4e992f94223",
          "BackupURL": "vfs:///opt/convoy/?backup=backup-0677c4e992f94223\u0026volume=volumetest",
          "CreatedTime": "Tue Oct 10 21:07:01 +0800 2017",
        "DriverName": "vfs",
        "SnapshotCreatedAt": "Tue Oct 10 21:05:12 +0800 2017",
        "SnapshotName": "snap1voll",
        "VolumeCreatedAt": "Tue Oct 10 21:04:12 +0800 2017",
        "VolumeName": "volumetest",
        "VolumeSize": "0"
        }
      }