Docker图形界面管理
之前都是使用命令行进行Docker的管理,这里简单介绍一下Docker的图形界面管理。之所以说简单介绍,是因为在生产环境都是集群,很少使用图形界面管理单台Docker主机,所以就演示记录一下,在个人测试时还是可以用到的。
一、使用Docker UI进行Docker管理
1)首先,下载Docker UI镜像
[root@centos7 ~]# docker pull abh1nav/dockerui:latest
Trying to pull repository docker.io/abh1nav/dockerui ...
latest: Pulling from docker.io/abh1nav/dockerui
a3ed95caeb02: Pull complete
5d3df020ecd3: Pull complete
bebf5a3b4dfb: Pull complete
e4452c0fe72b: Pull complete
6167d9726b07: Pull complete
53ebae19a314: Pull complete
Digest: sha256:a9c6c5393f561a0f42f41cfa80572b666e745d9b419569c42bac1e5cf9ceda32
Status: Downloaded newer image for docker.io/abh1nav/dockerui:latest
2)创建Docker容器
[root@centos7 ~]# docker run -d -p 9000:9000 -v /var/run/docker.sock:/docker.sock --name dockerui abh1nav/dockerui:latest -e="/docker.sock"
5f32d12629381614c11fa9d0c742326319c3bdbd8142a61d28e3d61a091b9555
[root@centos7 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5f32d1262938 abh1nav/dockerui:latest "./dockerui -e=/do..." 4 seconds ago Up 3 seconds 0.0.0.0:9000->9000/tcp dockerui
3)使用浏览器访问
二、使用Shipyard进行Docker管理
Shipyard也是基于Docker API实现的容器图形管理系统,支持container、image、engine、cluster等功能,可满足我们基本的容器部署需求。
Shipyard介绍:
shipyard是docker的web可视化界面管理工具,是建立在docker集群管理工具Citadel之上,可以管理镜像、容器、主机等资源的web图形化工具,包括core和extension两个版本,core即shipyard主要是把多个 Docker host上的 containers 统一管理(支持跨越多个host),extension即shipyard-extensions添加了应用路由和负载均衡、集中化日志、部署等。Shipyard是在Docker Swarm实现对容器、镜像、docker集群、仓库、节点进行管理的web系统。
Shipyard特性:
-
支持节点动态集群,可扩展节点的规模(swarm、etcd方案)
-
支持镜像管理、容器管理、节点管理等功能
-
可视化的容器管理和监控管理
-
在线容console终端
Shipyard服务介绍:
镜像名称 | 运行服务 | 描述 |
rethinkdb | shipyard数据库 | 一个NoSQL数据库,用于存储shipyard系统的数据,比如账号、节点、容器等信息 |
microbox/etcd | 服务注册、发现系统 | K/V存储系统,用于Swarm节点实现服务注册、发现。也支持consul、zookeeper。 |
shipyard/docker-proxy | docker API代理 | 连接本地/var/run/docker.sock代理,用于让Swarm Agent连接API管理。 |
swarm | swarm集群 | 官方管理Docker集群工具,使得多个engine为一个整体管理,对外提供Swarm manager API,用户就像操作单台engine一样。 |
shipyard/shipyard | shipyard前端 | 容器web管理系统,内部连接Swarm Manager管理容器和RethinkDB存储数据。 |
Shipyard分为自动部署和手动部署,相关文档参照:http://shipyard-project.com/deploy/ 。自动部署使用脚本自动完成,这里就做一下手动部署。
1)部署Datastore(也就是rethinkdb)
[root@centos7 ~]# docker run -itd --restart=always --name shipyard-rethinkdb rethinkdb
Unable to find image 'rethinkdb:latest' locally
Trying to pull repository docker.io/library/rethinkdb ...
latest: Pulling from docker.io/library/rethinkdb
ff4229790957: Pull complete
14645c851453: Pull complete
d4550880c6e0: Pull complete
4225e6f741d5: Pull complete
fb3b67be7bfa: Pull complete
Digest: sha256:f71d44a28322bf17aa0d3dd6ccbcba8ff4d59fdda8a132576d6c3132b6ed0e0c
Status: Downloaded newer image for docker.io/rethinkdb:latest
88d777e4b3b29b18b6fa86c6fdacc0188cf0f43792528264ed1a55c47597b566
[root@centos7 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
88d777e4b3b2 rethinkdb "rethinkdb --bind all" 5 seconds ago Up 4 seconds 8080/tcp, 28015/tcp, 29015/tcp shipyard-rethinkdb
2)部署发现服务(也就是etcd)
[root@centos7 ~]# docker run -itd --name shipyard-discovery -p 4001:4001 -p 7001:7001 --restart=always microbox/etcd -name discovery
Unable to find image 'microbox/etcd:latest' locally
Trying to pull repository docker.io/microbox/etcd ...
latest: Pulling from docker.io/microbox/etcd
8ded6e8ab3fd: Pull complete
bf8f85223d7a: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:941fd46b4eab265c65da9bfbf33397b853a7cef6c16df93a1e3fea7b4e47fc90
Status: Downloaded newer image for docker.io/microbox/etcd:latest
d6c0c946b42f541f91c1b183e99706054dc164fa66bcc91be13a3bdfe2dc272a
[root@centos7 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d6c0c946b42f microbox/etcd "/bin/etcd -name d..." 4 seconds ago Up 4 seconds 0.0.0.0:4001->4001/tcp, 0.0.0.0:7001->7001/tcp shipyard-discovery
3)部署docker代理服务(也就是docker-proxy)
[root@centos7 ~]# docker run -itd -p 2375:2375 --hostname=$HOSTNAME --restart=always --name shipyard-proxy -v /var/run/docker.sock:/var/run/docker.sock -e PORT=2375 shipyard/docker-proxy:latest
Unable to find image 'shipyard/docker-proxy:latest' locally
Trying to pull repository docker.io/shipyard/docker-proxy ...
latest: Pulling from docker.io/shipyard/docker-proxy
8f4ec95ceaee: Pull complete
ac77a345f217: Pull complete
43039e3ef672: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:da6bbd1a145581a940d44940cce0f43705d7f8ec552a4e97e77104ec1b6dc3d1
Status: Downloaded newer image for docker.io/shipyard/docker-proxy:latest
0eae3c9b83883d48fe211ed4f51753430a45a6fd10781019d24715ff1c982747
[root@centos7 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0eae3c9b8388 shipyard/docker-proxy:latest "/usr/local/bin/run" 11 seconds ago Up 10 seconds 0.0.0.0:2375->2375/tcp shipyard-proxy
4)部署Swarm Manager
[root@centos7 ~]# docker run -itd --restart=always --name shipyard-swarm-manager swarm:latest manage --host tcp://0.0.0.0:3375 etcd://192.168.49.40:4001
Unable to find image 'swarm:latest' locally
Trying to pull repository docker.io/library/swarm ...
latest: Pulling from docker.io/library/swarm
d85c18077b82: Pull complete
1e6bb16f8cb1: Pull complete
85bac13497d7: Pull complete
Digest: sha256:406022f04a3d0c5ce4dbdb60422f24052c20ab7e6d41ebe5723aa649c3833975
Status: Downloaded newer image for docker.io/swarm:latest
04575174ea8c0040a72840a44fab1f494d39dadde4fb097fa7fbb485c8320656
[root@centos7 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
04575174ea8c swarm:latest "/swarm manage --h..." 12 minutes ago Up 12 minutes 2375/tcp shipyard-swarm-manger
6)部署shipyard管理控制服务
[root@centos7 ~]# docker run -itd --restart=always --name shipyard-controller --link shipyard-rethinkdb:rethinkdb --link shipyard-swarm-manager:swarm -p 8080:8080 shipyard/shipyard:latest server -d tcp://swarm:3375
Unable to find image 'shipyard/shipyard:latest' locally
Trying to pull repository docker.io/shipyard/shipyard ...
latest: Pulling from docker.io/shipyard/shipyard
cb5507795515: Pull complete
fd711d385b34: Pull complete
9f2a509de079: Pull complete
a5251eb716bb: Pull complete
Digest: sha256:5f065362680fa4565dd150c8da3edd09b79a7a3010d3ceef20093c2a879187e0
Status: Downloaded newer image for docker.io/shipyard/shipyard:latest
464149d452e503340827afcaf1a87a114797ac7f0a6cbf15b7b6f0686f1fba15
[root@centos7 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
464149d452e5 shipyard/shipyard:latest "/bin/controller s..." 7 seconds ago Up 6 seconds 0.0.0.0:8080->8080/tcp shipyard-controller
7)使用浏览器访问
shipyard的登录界面,默认账号密码是admin/shipyard,登录即可。