{"id":142856,"date":"2019-05-08T12:02:03","date_gmt":"2019-05-08T04:02:03","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=142856"},"modified":"2019-04-17T11:03:44","modified_gmt":"2019-04-17T03:03:44","slug":"portainer-docker-tool","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/portainer-docker-tool.html","title":{"rendered":"Portainer\uff1a\u4e00\u4e2a\u7b80\u5355\u7684 Docker \u7ba1\u7406\u56fe\u5f62\u5de5\u5177"},"content":{"rendered":"
Rancher \u662f\u4e00\u4e2a\u5168\u9762\u7684\u5bb9\u5668\u7ba1\u7406\u5e73\u53f0\uff0c\u5b83\u53ef\u4ee5\u8ba9\u5bb9\u5668\u5728\u5404\u79cd\u57fa\u7840\u8bbe\u65bd\u5e73\u53f0\u7684\u751f\u4ea7\u73af\u5883\u4e0a\u90e8\u7f72\u548c\u8fd0\u884c\u66f4\u5bb9\u6613\u3002\u5b83\u63d0\u4f9b\u4e86\u8bf8\u5982\u591a\u4e3b\u673a\u7f51\u7edc\u3001\u5168\u5c40\/\u672c\u5730\u8d1f\u8f7d\u5747\u8861\u548c\u5377\u5feb\u7167\u7b49\u57fa\u7840\u8bbe\u65bd\u670d\u52a1\u3002\u5b83\u6574\u5408\u4e86\u539f\u751f Docker \u7684\u7ba1\u7406\u80fd\u529b\uff0c\u5982 Docker Machine \u548c Docker Swarm\u3002\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7528\u6237\u4f53\u9a8c\uff0c\u8ba9 DevOps \u7ba1\u7406\u5458\u5728\u66f4\u5927\u89c4\u6a21\u7684\u751f\u4ea7\u73af\u5883\u4e0a\u8fd0\u884c Docker\u3002<\/p>\n
\u7531\u4e8e Rancher \u662f\u4ee5\u8f7b\u91cf\u7ea7\u7684 Docker \u5bb9\u5668\u65b9\u5f0f\u8fd0\u884c\uff0c\u6240\u4ee5\u5b83\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\u3002Rancher \u662f\u7531\u4e00\u7ec4 Docker \u5bb9\u5668\u90e8\u7f72\u7684\u3002\u53ea\u9700\u8981\u7b80\u5355\u7684\u542f\u52a8\u4e24\u4e2a\u5bb9\u5668\u5c31\u80fd\u8fd0\u884c Rancher\u3002\u4e00\u4e2a\u5bb9\u5668\u7528\u4f5c\u7ba1\u7406\u670d\u52a1\u5668\uff0c\u53e6\u4e00\u4e2a\u5bb9\u5668\u5728\u5404\u4e2a\u8282\u70b9\u4e0a\u4f5c\u4e3a\u4ee3\u7406\u3002\u5728 Linux \u7cfb\u7edf\u4e0b\u7b80\u5355\u7684\u8fd0\u884c\u4e0b\u5217\u547d\u4ee4\u5c31\u80fd\u90e8\u7f72 Rancher\u3002<\/p>\n
Rancher \u670d\u52a1\u5668\u63d0\u4f9b\u4e86\u4e24\u4e2a\u4e0d\u540c\u7684\u5b89\u88c5\u5305\u6807\u7b7e\u5982 stable \u548c latest\u3002\u4e0b\u5217\u547d\u4ee4\u5c06\u4f1a\u62c9\u53d6\u9002\u5408\u7684 Rancher \u955c\u50cf\u5e76\u5b89\u88c5\u5230\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u3002Rancher \u670d\u52a1\u5668\u4ec5\u9700\u8981\u4e24\u5206\u949f\u5c31\u53ef\u4ee5\u542f\u52a8\u3002<\/p>\n
Rancher \u7684\u5b89\u88c5\u65b9\u6cd5\u6709\u591a\u79cd\u3002\u5728\u8fd9\u7bc7\u6559\u7a0b\u4e2d\u6211\u4eec\u4ec5\u8ba8\u8bba\u4e24\u79cd\u65b9\u6cd5\u3002<\/p>\n
\u8fd0\u884c\u4e0b\u5217\u547d\u4ee4\u4ee5\u5355\u4e00\u5bb9\u5668\u7684\u65b9\u5f0f\u5b89\u88c5 Rancher \u670d\u52a1\u5668\uff08\u5185\u5d4c\u6570\u636e\u5e93\uff09<\/p>\n
$ sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher\/server:stable\r\n$ sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher\/server:latest<\/pre>\n\u65b9\u6cd5 - 2<\/strong><\/span><\/div>\n\u4f60\u53ef\u4ee5\u5728\u542f\u52a8 Rancher \u670d\u52a1\u5668\u65f6\u6307\u5411\u5916\u90e8\u6570\u636e\u5e93\uff0c\u800c\u4e0d\u662f\u4f7f\u7528\u81ea\u5e26\u7684\u5185\u90e8\u6570\u636e\u5e93\u3002\u9996\u5148\u521b\u5efa\u6240\u9700\u7684\u6570\u636e\u5e93\uff0c\u6570\u636e\u5e93\u7528\u6237\u4e3a\u540c\u4e00\u4e2a\u3002<\/p>\n
> CREATE DATABASE IF NOT EXISTS cattle COLLATE = 'utf8_general_ci' CHARACTER SET = 'utf8';\r\n> GRANT ALL ON cattle.* TO 'cattle'@'%' IDENTIFIED BY 'cattle';\r\n> GRANT ALL ON cattle.* TO 'cattle'@'localhost' IDENTIFIED BY 'cattle';<\/pre>\n\u8fd0\u884c\u4e0b\u5217\u547d\u4ee4\u542f\u52a8 Rancher \u53bb\u8fde\u63a5\u5916\u90e8\u6570\u636e\u5e93\u3002<\/p>\n
$ sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher\/server \\\r\n--db-host myhost.example.com --db-port 3306 --db-user username --db-pass password --db-name cattle<\/pre>\n\u5982\u679c\u4f60\u60f3\u6d4b\u8bd5 Rancher 2.0\uff0c\u4f7f\u7528\u4e0b\u5217\u7684\u547d\u4ee4\u53bb\u542f\u52a8\u3002<\/p>\n
$ sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher\/server:preview<\/pre>\n\u901a\u8fc7 GUI \u8bbf\u95ee & \u5b89\u88c5 Rancher<\/strong><\/div>\n\u6d4f\u89c8\u5668\u8f93\u5165 http:\/\/hostname:8080 \u6216 http:\/\/server_ip:8080\u00a0\u53bb\u8bbf\u95ee rancher GUI.<\/p>\n
<\/p>\n
\u600e\u6837\u6ce8\u518c\u4e3b\u673a<\/strong><\/div>\n\u6ce8\u518c\u4f60\u7684\u4e3b\u673a URL \u5141\u8bb8\u5b83\u8fde\u63a5\u5230 Rancher API\u3002\u8fd9\u662f\u4e00\u6b21\u6027\u8bbe\u7f6e\u3002<\/p>\n
\u63a5\u4e0b\u6765\uff0c\u70b9\u51fb\u4e3b\u83dc\u5355\u4e0b\u9762\u7684 \u201cAdd a Host\u201d \u94fe\u63a5\u6216\u8005\u70b9\u51fb\u4e3b\u83dc\u5355\u4e0a\u7684 \u201cINFRASTRUCTURE >> Add Hosts\u201d\uff0c\u70b9\u51fb \u201cSave\u201d \u6309\u94ae\u3002<\/p>\n
<\/p>\n
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cRancher \u91cc\u7684\u8bbf\u95ee\u63a7\u5236\u8ba4\u8bc1\u7981\u6b62\u4e86\u8bbf\u95ee\uff0c\u56e0\u6b64\u6211\u4eec\u9996\u5148\u9700\u8981\u901a\u8fc7\u4e00\u4e9b\u65b9\u6cd5\u6253\u5f00\u8bbf\u95ee\u63a7\u5236\u8ba4\u8bc1\uff0c\u5426\u5219\u4efb\u4f55\u4eba\u90fd\u4e0d\u80fd\u8bbf\u95ee GUI\u3002<\/p>\n
\u70b9\u51fb \u201c>> Admin >> Access Control\u201d\uff0c\u8f93\u5165\u4e0b\u5217\u7684\u503c\u6700\u540e\u70b9\u51fb \u201cEnable Authentication\u201d \u6309\u94ae\u53bb\u6253\u5f00\u5b83\u3002\u5728\u6211\u8fd9\u91cc\uff0c\u662f\u901a\u8fc7 \u201clocal authentication\u201d \u7684\u65b9\u5f0f\u6253\u5f00\u7684\u3002<\/p>\n
\n
- \u201cLogin UserName\u201d\uff1a \u8f93\u5165\u4f60\u671f\u671b\u7684\u767b\u5f55\u540d<\/li>\n
- \u201cFull Name\u201d\uff1a \u8f93\u5165\u4f60\u7684\u5168\u540d<\/li>\n
- \u201cPassword\u201d\uff1a \u8f93\u5165\u4f60\u671f\u671b\u7684\u5bc6\u7801<\/li>\n
- \u201cConfirm Password\u201d\uff1a \u518d\u4e00\u6b21\u786e\u8ba4\u5bc6\u7801<\/li>\n<\/ul>\n
<\/p>\n
\u6ce8\u9500\u7136\u540e\u4f7f\u7528\u65b0\u7684\u767b\u5f55\u51ed\u8bc1\u91cd\u65b0\u767b\u5f55\uff1a<\/p>\n
<\/p>\n
\u73b0\u5728\uff0c\u6211\u80fd\u770b\u5230\u672c\u5730\u8ba4\u8bc1\u5df2\u7ecf\u88ab\u6253\u5f00\u3002<\/p>\n
<\/p>\n
\u600e\u6837\u6dfb\u52a0\u4e3b\u673a<\/strong><\/div>\n\u6ce8\u518c\u4f60\u7684\u4e3b\u673a\u540e\uff0c\u5b83\u5c06\u5e26\u4f60\u8fdb\u5165\u4e0b\u4e00\u4e2a\u9875\u9762\uff0c\u5728\u90a3\u91cc\u4f60\u80fd\u9009\u62e9\u4e0d\u540c\u4e91\u670d\u52a1\u63d0\u4f9b\u5546\u7684 Linux \u4e3b\u673a\u3002\u6211\u4eec\u5c06\u6dfb\u52a0\u4e00\u4e2a\u4e3b\u673a\u8fd0\u884c Rancher \u670d\u52a1\uff0c\u56e0\u6b64\u9009\u62e9\u201ccustom\u201d\u9009\u9879\u7136\u540e\u8f93\u5165\u5fc5\u8981\u7684\u4fe1\u606f\u3002<\/p>\n
\u5728\u7b2c 4 \u6b65\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684\u516c\u6709 IP\uff0c\u8fd0\u884c\u7b2c 5 \u6b65\u5217\u51fa\u7684\u547d\u4ee4\uff0c\u6700\u540e\u70b9\u51fb \u201cclose\u201d \u6309\u94ae\u3002<\/p>\n
$ sudo docker run -e CATTLE_AGENT_IP=\"192.168.56.2\" --rm --privileged -v \/var\/run\/docker.sock:\/var\/run\/docker.sock -v \/var\/lib\/rancher:\/var\/lib\/rancher rancher\/agent:v1.2.11 http:\/\/192.168.56.2:8080\/v1\/scripts\/16A52B9BE2BAB87BB0F5:1546214400000:ODACe3sfis5V6U8E3JASL8jQ\r\n\r\nINFO: Running Agent Registration Process, CATTLE_URL=http:\/\/192.168.56.2:8080\/v1\r\nINFO: Attempting to connect to: http:\/\/192.168.56.2:8080\/v1\r\nINFO: http:\/\/192.168.56.2:8080\/v1 is accessible\r\nINFO: Configured Host Registration URL info: CATTLE_URL=http:\/\/192.168.56.2:8080\/v1 ENV_URL=http:\/\/192.168.56.2:8080\/v1\r\nINFO: Inspecting host capabilities\r\nINFO: Boot2Docker: false\r\nINFO: Host writable: true\r\nINFO: Token: xxxxxxxx\r\nINFO: Running registration\r\nINFO: Printing Environment\r\nINFO: ENV: CATTLE_ACCESS_KEY=9946BD1DCBCFEF3439F8\r\nINFO: ENV: CATTLE_AGENT_IP=192.168.56.2\r\nINFO: ENV: CATTLE_HOME=\/var\/lib\/cattle\r\nINFO: ENV: CATTLE_REGISTRATION_ACCESS_KEY=registrationToken\r\nINFO: ENV: CATTLE_REGISTRATION_SECRET_KEY=xxxxxxx\r\nINFO: ENV: CATTLE_SECRET_KEY=xxxxxxx\r\nINFO: ENV: CATTLE_URL=http:\/\/192.168.56.2:8080\/v1\r\nINFO: ENV: DETECTED_CATTLE_AGENT_IP=172.17.0.1\r\nINFO: ENV: RANCHER_AGENT_IMAGE=rancher\/agent:v1.2.11\r\nINFO: Launched Rancher Agent: e83b22afd0c023dabc62404f3e74abb1fa99b9a178b05b1728186c9bfca71e8d<\/pre>\n<\/p>\n
\u7b49\u5f85\u51e0\u79d2\u949f\u540e\u65b0\u6dfb\u52a0\u7684\u4e3b\u673a\u5c06\u4f1a\u51fa\u73b0\u3002\u70b9\u51fb \u201cInfrastructure >> Hosts\u201d \u9875\u9762\u3002<\/p>\n
<\/p>\n","protected":false},"excerpt":{"rendered":"
Rancher \u662f\u4e00\u4e2a\u5168\u9762\u7684\u5bb9\u5668\u7ba1\u7406\u5e73\u53f0\uff0c\u5b83\u53ef\u4ee5\u8ba9\u5bb9\u5668\u5728\u5404\u79cd\u57fa\u7840\u8bbe\u65bd\u5e73\u53f0\u7684\u751f\u4ea7\u73af\u5883\u4e0a\u90e8\u7f72\u548c\u8fd0\u884c\u66f4\u5bb9\u6613\u3002\u5b83\u63d0\u4f9b\u4e86 […]<\/p>\n","protected":false},"author":323,"featured_media":85146,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-142856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/142856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=142856"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/142856\/revisions"}],"predecessor-version":[{"id":143172,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/142856\/revisions\/143172"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/85146"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=142856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=142856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=142856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}