Docker的Web UI管理:shipyard+swarm-(手动)安装&试用

来源:互联网 发布:js跨域上传文件 编辑:程序博客网 时间:2024/04/26 06:46

shipyard是对Docker进行管理的Web UI版。主要有以下特性: 
1. 镜像管理 
- 镜像的下载 
2. 容器管理 
- 容器的run、start、stop、rm 
3. registry管理 
- 增加、删除 
4. swarm集群管理:因为shipyard使用了swarm,所以可以对swarm集群中的集群进行管理

其中比较好玩的是:可以通过web ui在容器中执行命令,且类似attach之后的效果。

手动安装

shipyard 官方提供了两种安装方式,本文只记录了自己手动安装的过程.

  • 下载docker 所需要的镜像
<code class="hljs  has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">docker pull swarmdocker pull microbox/etcddocker pull shipyard/rethinkdb docker pull  shipyard/shipyard</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>
  • 启动rethinkdb:
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">docker run <span class="hljs-attribute" style="box-sizing: border-box;">-ti</span> <span class="hljs-attribute" style="box-sizing: border-box;">-d</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>name shipyard<span class="hljs-attribute" style="box-sizing: border-box;">-rethinkdb</span> docker<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>io/shipyard/rethinkdb</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
  • 启动etcd:
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">docker run <span class="hljs-attribute" style="box-sizing: border-box;">-ti</span> <span class="hljs-attribute" style="box-sizing: border-box;">-d</span> <span class="hljs-attribute" style="box-sizing: border-box;">-p</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4001</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4001</span> <span class="hljs-attribute" style="box-sizing: border-box;">-p</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7001</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7001</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>name shipyard<span class="hljs-attribute" style="box-sizing: border-box;">-discovery</span> docker<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>io/microbox/etcd <span class="hljs-attribute" style="box-sizing: border-box;">-name</span> discovery</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
  • 启动swarm manager: 
    • 将IP-OF-HOST替换为对应的ip;
    • 将SWARM-INNER-PORT换成对应的端口,默认2375.
    • 将SWARM-MAP-PORT换成映射到host机的ip,例如2376
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">docker run <span class="hljs-attribute" style="box-sizing: border-box;">-ti</span> <span class="hljs-attribute" style="box-sizing: border-box;">-d</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>name <span class="hljs-attribute" style="box-sizing: border-box;">-p</span> <span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span>SWARM<span class="hljs-attribute" style="box-sizing: border-box;">-MAP</span><span class="hljs-attribute" style="box-sizing: border-box;">-PORT</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;">:</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span>SWARM<span class="hljs-attribute" style="box-sizing: border-box;">-INNER</span><span class="hljs-attribute" style="box-sizing: border-box;">-PORT</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> shipyard-swarm-manager docker.io/swarm manage --host tcp://0.0.0.0:</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span>SWARM<span class="hljs-attribute" style="box-sizing: border-box;">-INNER</span><span class="hljs-attribute" style="box-sizing: border-box;">-PORT</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> etcd://</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span>IP<span class="hljs-attribute" style="box-sizing: border-box;">-OF</span><span class="hljs-attribute" style="box-sizing: border-box;">-HOST</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;">:4001</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
  • 启动swarm agent,将当前docker节点加入到集群中: 
    • 将IP-OF-HOST替换为对应的ip
    • 将IP-OF-ETCD-HOST换成etcd所在的docker节点ip。
    • 将LOCAL-DOCKER-PORT换成本机docker所监听的端口,例如2375
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">docker run <span class="hljs-attribute" style="box-sizing: border-box;">-ti</span> <span class="hljs-attribute" style="box-sizing: border-box;">-d</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>name shipyard<span class="hljs-attribute" style="box-sizing: border-box;">-swarm</span><span class="hljs-attribute" style="box-sizing: border-box;">-agent</span> docker<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>io/swarm <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">join</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>addr <span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span>IP<span class="hljs-attribute" style="box-sizing: border-box;">-OF</span><span class="hljs-attribute" style="box-sizing: border-box;">-HOST</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;">:</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">LOCAL</span><span class="hljs-attribute" style="box-sizing: border-box;">-DOCKER</span><span class="hljs-attribute" style="box-sizing: border-box;">-PORT</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;"> etcd://</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">[</span>IP<span class="hljs-attribute" style="box-sizing: border-box;">-OF</span><span class="hljs-attribute" style="box-sizing: border-box;">-ETCD</span><span class="hljs-attribute" style="box-sizing: border-box;">-HOST</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">]</span><span class="hljs-markup" style="box-sizing: border-box;">:4001</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
  • 启动shipyard controller:SWARM-INNER-PORT是上面配置的端口
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">docker run <span class="hljs-attribute" style="box-sizing: border-box;">-ti</span> <span class="hljs-attribute" style="box-sizing: border-box;">-d</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>name shipyard<span class="hljs-attribute" style="box-sizing: border-box;">-controller</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">link</span> shipyard<span class="hljs-attribute" style="box-sizing: border-box;">-rethinkdb</span>:rethinkdb <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">link</span> shipyard<span class="hljs-attribute" style="box-sizing: border-box;">-swarm</span><span class="hljs-attribute" style="box-sizing: border-box;">-manager</span>:swarm <span class="hljs-attribute" style="box-sizing: border-box;">-p</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8081</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8080</span> shipyard/shipyard server <span class="hljs-attribute" style="box-sizing: border-box;">-d</span> tcp:<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//swarm:[SWARM-INNER-PORT]</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

此时浏览器打开访问http://[IP-OF-HOST]:8081端口,便可以看到shipyard的页面了。默认的用户名密码是:admin/shipyard

0 0
原创粉丝点击