Docker使用阿里云加速|建立私有库registry

使用阿里云加速
镜像默认可以从 docker hub 上下载,这是 docker 官方的公共仓库,为我们免费提供了大量 已经容器化的应用镜像,避免我们重复的去造*。但是官方并没有在国内部署服务器, 我们可以使用阿里云进行镜像加速直接下载镜像

[root@server1 ~]# vim /etc/docker/daemon.json
{
  "registry-mirrors":["https://h7seebfh.mirror.aliyuncs.com"]
}

[root@server1 ~]# systemctl daemon-reload 
[root@server1 ~]# systemctl restart docker
# docker search  查询镜像
# docker pull   拉取镜像
# docker push   推送镜像
[root@server1 docker]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
743f2d6c1f65: Pull complete 
6bfc4ec4420a: Pull complete 
688a776db95f: Pull complete 
Digest: sha256:23b4dcdf0d34d4a129755fc6f52e1c6e23bb34ea011b315d87e193033bcd1b68
Status: Downloaded newer image for nginx:latest

建立registry

[root@server1 ~]# docker load -i registry2.tar
[root@server1 ~]# docker run -d --name registry -p 5000:5000 -v /opt/registry:/var/lib/registry registry:2
[root@server1 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
41647cbd10a3        registry:2          "/entrypoint.sh /etc…"   2 seconds ago       Up 2 seconds        0.0.0.0:5000->5000/tcp   registry

添加TLS加密

[root@server1 ~]# cd /tmp/docker/
[root@server1 docker]# mkdir -p certs
[root@server1 docker]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/westos.org.key -x509 -days 365 -out certs/westos.org.crt
Country Name (2 letter code) [XX]:cn
State or Province Name (full name) []:shaanxi
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:westos
Organizational Unit Name (eg, section) []:linux
Common Name (eg, your name or your server's hostname) []:westos.org
Email Address []:root@westos.org



[root@server1 docker]# docker run -d \
>   --restart=always \
>   --name registry \
>   -v /tmp/docker/certs:/certs \
>   -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
>   -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/westos.org.crt \
>   -e REGISTRY_HTTP_TLS_KEY=/certs/westos.org.key \
>   -p 443:443 \
>   -v /opt/registry:/var/lib/registry \
>   registry:2

[root@server1 docker]# netstat -anltp
tcp6       0      0 :::443                  :::*                    LISTEN      6669/docker-proxy 





[root@server1 certs]# cd /etc/docker/
[root@server1 certs]# mkdir certs.d

[root@server1 certs.d]# vim /etc/hosts
172.25.24.1 server1 westos.org


[root@server1 certs.d]# mkdir westos.org


[root@server1 westos.org]# cp /tmp/docker/certs/westos.org.crt ca.crt
[root@server1 westos.org]# pwd
/etc/docker/certs.d/westos.org

[root@server1 certs.d]# docker tag game2048:latest westos.org/game2048
[root@server1 westos.org]# docker push westos.org/game2048
The push refers to repository [westos.org/game2048]
88fca8ae768a: Pushed 
6d7504772167: Pushed 
192e9fad2abc: Pushed 
36e9226e74f8: Pushed 
011b303988d2: Pushed 
latest: digest: sha256:8a34fb9cb168c420604b6e5d32ca6d412cb0d533a826b313b190535c03fe9390 size: 1364

在server2上获取镜像

[root@server2 docker]# mkdir /etc/docker/certs.d/westos.org/ -p

[root@server1 westos.org]# scp ca.crt root@172.25.76.2:/etc/docker/certs.d/westos.org/

[root@server2 docker]# vim /etc/hosts
172.25.24.1 server1 westos.org

[root@server2 docker]# systemctl start docker
[root@server2 docker]# docker pull westos.org/game2048
Using default tag: latest
latest: Pulling from game2048
534e72e7cedc: Pull complete 
f62e2f6dfeef: Pull complete 
fe7db6293242: Pull complete 
3f120f6a2bf8: Pull complete 
4ba4e6930ea5: Pull complete 
Digest: sha256:8a34fb9cb168c420604b6e5d32ca6d412cb0d533a826b313b190535c03fe9390
Status: Downloaded newer image for westos.org/game2048:latest

建立用户认证

[root@server1 westos.org]# cd /tmp/docker/
[root@server1 docker]# ls
certs  Dockerfile  dvd.repo  nginx-1.15.8.tar.gz  website
[root@server1 docker]# mkdir auth
[root@server1 docker]# docker run --rm --entrypoint htpasswd registry:2 -Bbn zcx redhat > auth/htpasswd
[root@server1 docker]# cat auth/htpasswd 
zcx:$2y$05$25GzGOQtb6BgcYDiKxpy8OSj2FfX0yn7HA5KjPRmZhsEgcbuVbVTa

[root@server1 docker]# docker rm -f  registry 
registry
[root@server1 docker]# docker run -d   --restart=always   --name registry   -v /tmp/docker/certs:/certs   -e REGISTRY_HTTP_ADDR=0.0.0.0:443   -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/westos.org.crt   -e REGISTRY_HTTP_TLS_KEY=/certs/westos.org.key   -p 443:443   -v /opt/registry:/var/lib/registry  -v /tmp/docker/auth:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd  registry:2
7cd30da8595f7cae1f7e5e653eb1363b727f85f4b3da2db31ea73ecc26d5f1a2
[root@server1 docker]# docker login westos.org
Username: zcx
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@server1 docker]# cat /root/.docker/config.json 
{
	"auths": {
		"westos.org": {
			"auth": "emN4OnJlZGhhdA=="
		}
	},
	"HttpHeaders": {
		"User-Agent": "Docker-Client/18.06.1-ce (linux)"
	}

}[root@server1 docker]# docker logout westos.org
Removing login credentials for westos.org

#测试上传
[root@server1 docker]# docker tag ubuntu:v1 westos.org/ubuntu
[root@server1 docker]# docker push westos.org/ubuntu
The push refers to repository [westos.org/ubuntu]
0140d922175b: Preparing 
5f70bf18a086: Preparing 
11083b444c90: Preparing 
9468150a390c: Preparing 
56abdd66ba31: Preparing 
no basic auth credentials                             #没登陆所以失败


[root@server1 docker]# docker login westos.org
Username: zcx
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@server1 docker]# docker push westos.org/ubuntu
The push refers to repository [westos.org/ubuntu]
0140d922175b: Pushed 
5f70bf18a086: Pushed 
11083b444c90: Pushed 
9468150a390c: Pushed 
56abdd66ba31: Pushed 
latest: digest: sha256:0a210a84b4e5bbd7c7cc1001f9d25a35f3ca3a0c2ba993a77398c208d5df2b6a size: 1358

容器四种网络模式
#桥接模式
[root@server1 images]# docker load -i ubuntu.tar
Loaded image: ubuntu:latest
[root@server1 images]# docker run -it -name vm1 ubuntu
unknown shorthand flag: ‘n’ in -name
See ‘docker run --help’.
[root@server1 images]# docker run -it --name vm1 ubuntu
root@cb57ede03f5b:/# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
62: eth0@if63: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:03 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.3/16 brd 172.17.255.255 scope global eth0
valid_lft forever preferred_lft forever
root@cb57ede03f5b:/# [root@server1 images]# brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.0242fffa7ac3 no veth0af2fd1
veth41ca9df

#host模式
[root@server1 images]# docker run -it --name vm2 --net host ubuntu
root@server1:/# ip addr

#none模式
[root@server1 images]# docker run -it --name vm3 --network=none ubuntu
root@e02e43e1346d:/# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever

#container模式
docker run -it --name vm3 --net container:vm1 ubuntu

#创建自定义网桥
[root@server1 images]# docker network create --driver bridge my_net1
b8efe9b4aa135d836aaa4b3faf37b432ed946cf1d944732a6202cf3988d8badc

[root@server1 images]# docker run -it --name vm1 --network=my_net1 ubuntu
root@2ff81c3dad59:/# ip addr

[root@server1 images]# docker run -it --name vm2 --network=my_net1 ubuntu
root@1ee392d6b978:/# ip addr

[root@server1 images]# docker network create --subnet=172.21.0.0/24 --gateway=172.21.0.1 my_net2
c20edb1595545599a7803a697f3d4a23840a7bc2561edd70b2729754dd67f1b8
[root@server1 images]# docker run -it --name vm3 --network=my_net2 --ip=172.21.0.10 ubuntu
root@fe2f3a42caa1:/# ip addr

创建macvlan网络

在server1 server2 添加eth1网卡
BOOTPROTO=none
DEVICE=eth1
ONBOOT=yes

[root@server1 network-scripts]# ip link set eth1 promisc on
[root@server1 network-scripts]# docker ps -qa
fe2f3a42caa1
1ee392d6b978
2ff81c3dad59
52ad16bca42d
7cd30da8595f
[root@server1 network-scripts]# docker rm -f docker ps -qa
fe2f3a42caa1
1ee392d6b978
2ff81c3dad59
52ad16bca42d
7cd30da8595f
[root@server1 network-scripts]# docker network create -d macvlan --subnet=172.22.0.0/24 --gateway=172.22.0.1 macvlan1
474ab39ba61a9ed4bfa7adada0105a2242b999bb7427eaf4cf7c81967f24d33d
[root@server1 network-scripts]# docker network rm macvlan1
macvlan1
[root@server1 network-scripts]# docker network create -d macvlan --subnet=172.22.0.0/24 --gateway=172.22.0.1 -o parent=eth1 macvlan1
a6f12a4e00d5021fb244de44d181e051bf458d9410afa968773e1c6fc0cef493
[root@server1 network-scripts]# brctl show
bridge name bridge id STP enabled interfaces
br-b8efe9b4aa13 8000.02427968c3e6 no
br-c20edb159554 8000.02429027fc48 no
docker0 8000.0242fffa7ac3 no
[root@server1 network-scripts]# docker network rm my_net1
my_net1
[root@server1 network-scripts]# docker network rm my_net2
my_net2
[root@server1 network-scripts]# docker network ls
NETWORK ID NAME DRIVER SCOPE
dc36bf377f76 bridge bridge local
9aa1342f126f host host local
a6f12a4e00d5 macvlan1 macvlan local
1446c909f32a none null local
[root@server1 network-scripts]# brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.0242fffa7ac3 no
[root@server1 network-scripts]# docker run -it --name vm1 --network=macvlan1 --ip=172.22.0.10 ubuntu
root@5ab5a724731c:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
75: eth0@if72: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 02:42:ac:16:00:0a brd ff:ff:ff:ff:ff:ff
inet 172.22.0.10/24 brd 172.22.0.255 scope global eth0
valid_lft forever preferred_lft forever
root@5ab5a724731c:/# [root@server1 network-scripts]#
[root@server1 network-scripts]# docker run -it --name vm2 --network=macvlan1 --ip=172.22.0.11 ubuntu
root@ca6f7429439b:/# [root@server1 network-scripts]# cd
[root@server1 ~]# cd images/
[root@server1 images]# scp ubuntu.tar server2:
root@server2’s password:
ubuntu.tar 100% 188MB 20.9MB/s 00:09

[root@server2 network-scripts]# ip link set eth1 promisc on
[root@server2 network-scripts]# logout
Connection to 172.25.24.2 closed.
[kiosk@foundation24 ~]$ ssh root@172.25.24.2
root@172.25.24.2’s password:
Last login: Sun May 26 10:52:46 2019 from foundation24.ilt.example.com
[root@server2 ~]# docker network create -d macvlan --subnet=172.22.0.0/24 --gateway=172.22.0.1 -o parent=eth1 macvlan1
4f2c9b3c71c8e0ed6afa79caafb2b9baaeaba14345d77d1f71bd73eab2da0627
[root@server2 ~]# docker load -i ubuntu.tar
56abdd66ba31: Loading layer 196.8MB/196.8MB
9468150a390c: Loading layer 208.9kB/208.9kB
11083b444c90: Loading layer 4.608kB/4.608kB
5f70bf18a086: Loading layer 1.024kB/1.024kB
Loaded image: ubuntu:latest
[root@server2 ~]# docker run -it --name vm3 --network=macvlan1 --ip=172.22.0.12 ubuntu
root@46fbcabd2fff:/# ping 172.22.0.10
PING 172.22.0.10 (172.22.0.10) 56(84) bytes of data.
64 bytes from 172.22.0.10: icmp_seq=1 ttl=64 time=0.557 ms
64 bytes from 172.22.0.10: icmp_seq=2 ttl=64 time=1.01 ms
^C
— 172.22.0.10 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.557/0.787/1.017/0.230 ms

#使不同macvlan网络主机可以互连
[root@server1 images]# docker network create -d macvlan --subnet=172.23.0.0/24 --gateway=172.23.0.1 -o parent=eth1.1 macvlan2
604e44fd2df6c6c8335f7d6b24b9b58c3fe5de54e162e9fdf320f710d8fedf0c
[root@server1 images]# docker run -it --name vm3 --network=macvlan2 --ip=172.23.0.11 ubuntu
root@1d47029fda77:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
78: eth0@if77: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 02:42:ac:17:00:0b brd ff:ff:ff:ff:ff:ff
inet 172.23.0.11/24 brd 172.23.0.255 scope global eth0
valid_lft forever preferred_lft forever
root@1d47029fda77:/# ping 172.22.0.10
PING 172.22.0.10 (172.22.0.10) 56(84) bytes of data.
^C
— 172.22.0.10 ping statistics —
2 packets transmitted, 0 received, 100% packet loss, time 1000ms

root@1d47029fda77:/# [root@server1 images]#
[root@server1 images]# docker network connect macvlan1 vm3
[root@server1 images]# docker attach vm3
root@1d47029fda77:/#
root@1d47029fda77:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
78: eth0@if77: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 02:42:ac:17:00:0b brd ff:ff:ff:ff:ff:ff
inet 172.23.0.11/24 brd 172.23.0.255 scope global eth0
valid_lft forever preferred_lft forever
79: eth1@if72: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 02:42:ac:16:00:02 brd ff:ff:ff:ff:ff:ff
inet 172.22.0.2/24 brd 172.22.0.255 scope global eth1
valid_lft forever preferred_lft forever
root@1d47029fda77:/# ping 172.22.0.10
PING 172.22.0.10 (172.22.0.10) 56(84) bytes of data.
64 bytes from 172.22.0.10: icmp_seq=1 ttl=64 time=0.073 ms
64 bytes from 172.22.0.10: icmp_seq=2 ttl=64 time=0.049 ms
^C
— 172.22.0.10 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.049/0.061/0.073/0.012 ms

#Docker卷管理
[root@server1 ~]# docker run -it --name vm1 -v /tmp/data1 -v /tmp/data2:/data2:ro -v /etc/yum.repos.d/rhel.repo:/rhel.repo:ro ubuntu
[root@server1 ~]# docker volume ls
DRIVER VOLUME NAME
local 28d0a83780680bde4e7b3a31fd70b50da011a2ff543e27a9cf97201b8641fb36
local e9fc8726131cbe181b648615aa2915e4f3c21cd3c3889e8d7584edc21f246b07
[root@server1 ~]# docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
e9fc8726131cbe181b648615aa2915e4f3c21cd3c3889e8d7584edc21f246b07
[root@server1 ~]# docker run -d --name registry registry:2
0fddecaa45b3ab8fd07a2168869b5263742357b86b875c6c3783a56b2f013a74
[root@server1 ~]# docker volume ls
DRIVER VOLUME NAME
local 28d0a83780680bde4e7b3a31fd70b50da011a2ff543e27a9cf97201b8641fb36
local 9b61d748f1e25bf4f7a3669fabd25413fceedc322b06b81c81278b2bbd04dbde
[root@server1 ~]# docker inspect registry
“Source”: “/var/lib/docker/volumes/9b61d748f1e25bf4f7a3669fabd25413fceedc322b06b81c81278b2bbd04dbde/_data”,
[root@server1 ~]# cd /var/lib/docker/volumes/9b61d748f1e25bf4f7a3669fabd25413fceedc322b06b81c81278b2bbd04dbde/_data
[root@server1 _data]# docker rm -f registry
registry
[root@server1 _data]# docker volume ls
DRIVER VOLUME NAME
local 28d0a83780680bde4e7b3a31fd70b50da011a2ff543e27a9cf97201b8641fb36
local 9b61d748f1e25bf4f7a3669fabd25413fceedc322b06b81c81278b2bbd04dbde
[root@server1 _data]# docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:

[root@server1 _data]# docker run -d --name registry -v registry:/var/lib/registry registry:2
e4574dea0f6eefd1db49c529dfa634f463552cd3ecc1c5851855f46ae25ad1bb

#使用创建的volume
[root@server1 volumes]# docker volume create vol1
vol1
[root@server1 volumes]# docker volume create vol2
vol2
[root@server1 volumes]# docker run -d --name registry -v vol1:/var/lib/registry registry:2
8e2d5415626209fcdb94ae8681345a27a9a19b3d2e35a959cdaf294e98d9e4b2

#使用nfs convoy 实现数据同步
[root@server1 volumes]# mkdir /mnt/nfs
[root@server1 volumes]# vim /etc/exports
/mnt/nfs *(rw,no_root_squash)
[root@server1 volumes]# systemctl start nfs
[root@server1 volumes]# showmount -e localhost
Export list for localhost:
/mnt/nfs *
[root@server1 volumes]# systemctl start rpcbind
[root@server1 volumes]# systemctl enable rpcbind
[root@server1 volumes]# cd
[root@server1 ~]# ls
convoy.tar.gz docker game2048.tar images registry2.tar root@172.25.24.2
[root@server1 ~]# tar zxf convoy.tar.gz
[root@server1 ~]# ls
convoy convoy.tar.gz docker game2048.tar images registry2.tar root@172.25.24.2
[root@server1 ~]# cd convoy/
[root@server1 convoy]# ls
convoy convoy-pdata_tools SHA1SUMS
[root@server1 convoy]# cp convoy convoy-pdata_tools /usr/local/bin/
[root@server1 convoy]# cd /usr/local/bin/
[root@server1 bin]# ls
convoy convoy-pdata_tools

[root@server1 ~]# mkdir /etc/docker/plugins/
[root@server1 ~]# cd /etc/docker/
[root@server1 docker]# cd plugins/
[root@server1 plugins]# ls
[root@server1 plugins]# echo “unix:///var/run/convoy/convoy.sock” > /etc/docker/plugins/convoy.spec
[root@server1 plugins]# ls
convoy.spec
[root@server1 plugins]# cat convoy.spec
unix:///var/run/convoy/convoy.sock
[root@server1 plugins]# convoy daemon --drivers vfs --driver-opts vfs.path=/mnt/nfs &
[1] 12639
[root@server1 plugins]# DEBU[0000] Creating config at /var/lib/rancher/convoy pkg=daemon
DEBU[0000] driver=vfs driver_opts=map[vfs.path:/mnt/nfs] event=init pkg=daemon reason=prepare root=/var/lib/rancher/convoy
DEBU[0000] driver=vfs event=init pkg=daemon reason=complete
DEBU[0000] Registering GET, /backups/list pkg=daemon
DEBU[0000] Registering GET, /backups/inspect pkg=daemon
DEBU[0000] Registering GET, /info pkg=daemon
DEBU[0000] Registering GET, /volumes/list pkg=daemon
DEBU[0000] Registering GET, /volumes/ pkg=daemon
DEBU[0000] Registering GET, /snapshots/ pkg=daemon
DEBU[0000] Registering POST, /volumes/create pkg=daemon
DEBU[0000] Registering POST, /volumes/mount pkg=daemon
DEBU[0000] Registering POST, /volumes/umount pkg=daemon
DEBU[0000] Registering POST, /snapshots/create pkg=daemon
DEBU[0000] Registering POST, /backups/create pkg=daemon
DEBU[0000] Registering DELETE, /volumes/ pkg=daemon
DEBU[0000] Registering DELETE, /snapshots/ pkg=daemon
DEBU[0000] Registering DELETE, /backups pkg=daemon
DEBU[0000] Registering plugin handler POST, /Plugin.Activate pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Create pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Remove pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Mount pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Unmount pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Path pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Get pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.List pkg=daemon

[root@server1 plugins]# cd /mnt/nfs/
[root@server1 nfs]# ls
config

[root@server2 ~]# tar zxf convoy.tar.gz
[root@server2 ~]# cd convoy/
[root@server2 convoy]# ls
convoy convoy-pdata_tools SHA1SUMS
[root@server2 convoy]# cp convoy convoy-pdata_tools /usr/local/bin/
[root@server2 convoy]# cd
[root@server2 ~]# mkdir /etc/docker/plugins/
[root@server2 ~]# echo “unix:///var/run/convoy/convoy.sock” > /etc/docker/plugins/convoy.spec
[root@server2 ~]# convoy daemon --drivers vfs --driver-opts vfs.path=/mnt/nfs &
[1] 4258
[root@server2 ~]# DEBU[0000] Creating config at /var/lib/rancher/convoy pkg=daemon
DEBU[0000] driver=vfs driver_opts=map[vfs.path:/mnt/nfs] event=init pkg=daemon reason=prepare root=/var/lib/rancher/convoy
DEBU[0000] driver=vfs event=init pkg=daemon reason=complete
DEBU[0000] Registering GET, /info pkg=daemon
DEBU[0000] Registering GET, /volumes/list pkg=daemon
DEBU[0000] Registering GET, /volumes/ pkg=daemon
DEBU[0000] Registering GET, /snapshots/ pkg=daemon
DEBU[0000] Registering GET, /backups/list pkg=daemon
DEBU[0000] Registering GET, /backups/inspect pkg=daemon
DEBU[0000] Registering POST, /backups/create pkg=daemon
DEBU[0000] Registering POST, /volumes/create pkg=daemon
DEBU[0000] Registering POST, /volumes/mount pkg=daemon
DEBU[0000] Registering POST, /volumes/umount pkg=daemon
DEBU[0000] Registering POST, /snapshots/create pkg=daemon
DEBU[0000] Registering DELETE, /volumes/ pkg=daemon
DEBU[0000] Registering DELETE, /snapshots/ pkg=daemon
DEBU[0000] Registering DELETE, /backups pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Remove pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Mount pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Unmount pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Path pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Get pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.List pkg=daemon
DEBU[0000] Registering plugin handler POST, /Plugin.Activate pkg=daemon
DEBU[0000] Registering plugin handler POST, /VolumeDriver.Create pkg=daemon

[root@server2 ~]# cd /mnt/nfs/
[root@server2 nfs]# ls
config
[root@server2 nfs]# convoy create vol1
DEBU[0119] Calling: POST, /volumes/create, request: POST, /v1/volumes/create pkg=daemon
DEBU[0119] event=create object=volume opts=map[VolumeIOPS:0 PrepareForVM:false Size:0 BackupURL: VolumeName:vol1 VolumeDriverID: VolumeType:] pkg=daemon reason=prepare volume=vol1
DEBU[0119] Created volume event=create object=volume pkg=daemon reason=complete volume=vol1
DEBU[0119] Response: vol1 pkg=daemon
vol1
[root@server2 nfs]# ls
config vol1

[root@server2 nfs]# docker run -it --name vm1 -v vol1:/data --volume-driver=convoy ubuntu

root@1b59277e9396:/# cd data/
root@1b59277e9396:/data# touch file{1…10}
root@1b59277e9396:/data# ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9
root@1b59277e9396:/data# [root@server2 nfs]#
[root@server2 nfs]#
[root@server2 nfs]# ls
config vol1
[root@server2 nfs]# cd vol1/
[root@server2 vol1]# ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9

[root@server1 ~]# cd /mnt/nfs/
[root@server1 nfs]# ls
config vol1
[root@server1 nfs]# cd vol1/
[root@server1 vol1]# ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9

[root@server1 nfs]# docker run -it --name vm1 -v vol1:/data --volume-driver=convoy ubuntu

root@08f851c535ff:/# cd data/
root@08f851c535ff:/data# ls
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9

上一篇:freebsd安装gnome3桌面环境


下一篇:最全的 pip 使用指南,50% 你可能没用过