# dockerHosts **Repository Path**: sorc/docker-hosts ## Basic Information - **Project Name**: dockerHosts - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-16 - **Last Updated**: 2024-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # docker hosts监控 ## 功能说明 监控docker容器启停事件,更新或删除hosts ## 编译安装 ### 配置仓库 ```shell require ( github.com/docker/docker v23.0.3+incompatible github.com/kardianos/service v1.2.2 github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/sirupsen/logrus v1.9.3 gopkg.in/yaml.v3 v3.0.1 ) go clean -modcache go env -w GO111MODULE=on go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,https://goproxy.io,direct go env|grep PROXY go env -w GONOPROXY= go env -w GOPROXY=https://goproxy.cn,direct sudo apt-get install go-dep curl -x "http://127.0.0.1:1082" https://raw.githubusercontent.com/golang/dep/master/install.sh | sh go get github.com/docker/docker go get github.com/kardianos/service go get github.com/sirupsen/logrus go get github.com/lestrrat-go/file-rotatelogs ``` ### 交叉编译 ```shell CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/docker-hosts_linux_amd64 main.go CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o build/docker-hosts_linux_arm64 main.go CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o build/docker-hosts_mac_amd64 main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o build/docker-hosts_windows_amd64.exe main.go CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/docker-hosts main.go ``` ## 使用说明 #### 命令实例 ```shell # 给执行权限 chmod +x docker-hosts # 查看命令帮助 ./docker-hosts help # 直接运行 ./docker-hosts run # 服务端安装 ./docker-hosts install # 启动服务 systemctl start docker-hosts # 停止服务 systemctl stop docker-hosts # 查看服务状态 systemctl status docker-hosts ```