docker编排创建工具Humpback

2019-11-01  本文已影响0人  oopp8

Humpback文档

一个轻量级的容器管理工具—Humpback。它的思路跟咱们常用的操作系统监控差不多,在各个被操作的机器上安装完docker后再安装它的agent,然后在一台master上部署它的web系统就可以了,实现起来简单方便,单机多节点都可以,非常适合中小公司尤其是创业公司来使用。

一、安装Humpback和Agent

docker run -d --net=host --restart=always -e HUMPBACK_LISTEN_PORT=8000 -v /app/humpback-web/dbFiles:/humpback-web/dbFiles --name humpback-web humpbacks/humpback-web
docker run -d -ti --net=host --restart=always -e DOCKER_API_VERSION=v1.21 -v /var/run/:/var/run/:rw --name=humpback-agent humpbacks/humpback-agent

二、设置

进入http://localhost:8000 输入admin、123456进入界面。

image.png

管理容器和镜像


image.png

三、搭建私有仓库

1、安装Registry

为了定制一些配置,和在 Humpback 中使用,我们还需要提供一个定制化的配置文件(使用yml来编写配置文件)
sudo nano /app/registry/config.yml

version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  secret: docker-registry
  headers:
    X-Content-Type-Options: [nosniff]
    Access-Control-Allow-Headers: ['Origin,Accept,Content-Type,Authorization']
    Access-Control-Allow-Origin: ['*']
    Access-Control-Allow-Methods: ['GET,POST,PUT,DELETE']
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3

注意:storage 设置提交到仓库的镜像,应该存储在什么地方;http 节点中需要配置端口和安全码,其中关键的地方在于 http.headers 的配置。如上的配置,是为了能够跨域访问仓库API,这是要让仓库搭配 Humpback 必须的设置,Humpback会在浏览器端对仓库发起请求。

docker run -d -p 5000:5000 --net=host --restart=always -v /app/registry/registry/:/var/lib/registry/ -v /app/registry/config.yml:/etc/docker/registry/config.yml --name registry registry

浏览器访问http://localhost:5000/v2/_catalog正常情况会返回空的json对象。

2、Registry测试使用

a、先从官方镜像拉取ubuntu测试镜像docker pull ubuntu
b、为镜像打上tag,创建自己的镜像docker tag ubuntu 192.168.1.5:5000/ubuntu
[命名方式:ip:port/image_name:version]

3、配置镜像服务器地址

sudo nano /etc/docker/daemon.json

// 多个服务器的写法
{
    "registry-mirrors": ["http://f1361db2.m.daocloud.io"],
    "insecure-registries": ["registry1的IP地址:端口号","registry2的IP地址:端口号"]
}

第一个为容器镜像加速地址,第二个为新增的自己的镜像服务器地址。

附:Docker Hub 镜像加速器列表

镜像加速器 镜像加速器地址 专属加速器? 其它加速?
Docker 中国官方镜像 https://registry.docker-cn.com DockerHub
DaoCloud 镜像站 http://f1361db2.m.daocloud.io 可登录,系统分配 Docker Hub
Azure 中国镜像 https://dockerhub.azk8s.cn Docker Hub、GCR、Quay
科大镜像站 https://docker.mirrors.ustc.edu.cn Docker Hub、GCR、Quay
阿里云 https://<your_code>.mirror.aliyuncs.com 需登录,系统分配 Docker Hub
七牛云 https://reg-mirror.qiniu.com Docker Hub、GCR、Quay
网易云 https://hub-mirror.c.163.com Docker Hub
腾讯云 https://mirror.ccs.tencentyun.com Docker Hub

4、重启服务:

service docker restart

5、验证配置

docker info看Insecure Registries节点是否多了一个配置。

6、推送镜像

docker push 192.168.1.5:5000/ubuntu

7、浏览器查看查看镜像http://localhost:5000/v2/_catalog

image.png

8、拉取镜像

docker pull 192.168.1.5:5000/ubuntu

四、Humpback中Registry配置

System Config Hub
上一篇下一篇

猜你喜欢

热点阅读