背景
起初作为一个个人开发者, 服务器的资源有限, 上手就直接使用k8s有点不太现实, 所以Docker成为了不二之选,
但是Docker要解决远程CI自动部署的问题, 在这样一个背景下DockerPanel工具产生了
服务器端部署
dockerpanel nodeagent直接挂载本机的docker.sock进行通信
docker pull hub.feinian.net/public/dockerpanel_nodeagent:latest && \docker rm dockerpanel_nodeagent -f || true && \docker run -dit --name dockerpanel_nodeagent --restart=always -p 3231:8080 \-v /run/docker.sock:/var/run/docker.sock \-v /data/dockerpanel:/app/config \hub.feinian.net/public/dockerpanel_nodeagent:latest
运行之后会在/app/config目录下自动生成配置文件, 如下:
AuthenticationConfig: 自动生成, 访问的用户名密码
RegistryConfig: 不会自动生成, 需要手动加, 要访问的镜像仓库的地址信息, 可以配置多个
{ "AuthenticationConfig": { "UseSecurity": true, "UserName": "niusys", "Password": "xxxxxxxx" }, "RegistryConfig": [ { "ServerAddress": "hub.feinian.net", "UserName": "admin", "Password": "hubor password" } ]}
这个时候就可以通过浏览器访问http://服务器ip:3231端口访问, 用户名密码是配置文件中的: UserName/Password
通过CURL部署
这里定制的部分支持 prots/links/hosts/envs/volumns
curl -s --location -w "%{http_code}"--request POST 'http://dockerpanel_nodeagent:3231/container/replaceimage'--header 'Authorization:Basic basic认证的密钥, 参考下面的Authorization获取'--header 'Content-Type:application/json'--data-raw '{"name":"'$APP_NAME'","image":"'$HUB_HOST'/'$APP_NAME':'$IMAGE_VERSION'","ports":[],"links":[],"hosts":[]}'
获取Authorizaton部分
在dockerpanel网页登录时, 开启f12窗口, 拦截到的请求中可以看到最终转换之后的Authorization认证密钥