Docker 部署入门笔记

一、Docker 部署
1、配置docker yum源
[root@ docker]# cat /etc/yum.repos.d/docker-main.repo
[docker-main-repo]
name=Docker main Repository
baseurl=https://get.daocloud.io/docker/yum-repo/main/CentOS/7
enabled=1
gpgcheck=1
gpgkey=https://get.daocloud.io/docker/yum/gpg

2、安装docker 17ce版本包
[root@ docker]# yum install docker-engine –y

3、查看docker版本
[root@ docker]# docker --version
Docker version 17.05.0-ce, build 89658be

4、配置防火墙

firewall-cmd --add-port=2377/tcp --permanent

firewall-cmd --add-port=7946/tcp --permanent

firewall-cmd --add-port=7946/udp --permanent

firewall-cmd --add-port=4789/udp --permanent

firewall-cmd --reload**

5、在安装docker时,docker在/etc/下自动生成一个docker文件,导致docker启动时不能创建/etc/docker目录,不能生成/etc/docker/daemon.json 文件,所以不能启动,如果没有该文件没法同步docker镜像,创建文件后需要重启docker服务
[root@ docker]# cat /etc/docker/daemon.json
{
"insecure-registries":["docker-registry.istarshine.net.cn:5000"],
"log-driver":"json-file",
"log-opts":{"max-size":"1024m","max-file":"2"}
}
[root@ ~]# systemctl restart docker.service
二、加入docker集群

在manger管理主机上运行
1、查看管理主机token值
[root@filters5_191_6 ~]# docker swarm join-token worker
To add a worker to this swarm, run the following command:

docker swarm join \
--token SWMTKN-1-4p4djbee1kqcss8x5prfzg6v01x0y7hfa7rqob6rffg6e2p2wq-278qafb9ptpqtfebr0kyngi0b \
192.168.191.6:2377

2、查看集群节点列表
[root@filters ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
0y4ga216x49nd9zt821afe45p * filters5_191_6 Ready Active Reachable
56mgklq3iyf0ajioytmtr0b44 filters5_191_10 Ready Active
b5mljua4e0tchrrk871ggbw7r filters5_191_7 Ready Active Reachable
gxm1gvh8lx2eja36a4cms9w98 filters5_182_212 Ready Active
hgweoxc5vmy9g30uyozmbumhj filters5_182_213 Ready Active
lluom23ugtfuiwphcye2frbmd filters5_182_215 Ready Active
om0ezdbqzdvavn8z8d844osbo filters5_182_214 Ready Active
t00tu1qs7wbll2fg2accsx7wf filters5_191_4 Ready Active Leader
tk89xphvsg16rz7b7l6lam4xv filters5_191_9 Ready Active
xbcx4hx2lq3ji8zog2ayzctat filters5_191_8 Ready Active Reachable
y3pnrw9jt69vkfiuxrs0co7ke filters5_191_5 Ready Active Reachable

在节点主机上运行

添加节点到docker集群
命令用法
docker swarm join --token <manger节点的token值> manger node ip:port

[root@dockernode~]#docker swarm join --token SWMTKN-1-4p4djbee1kqcss8x5prfzg6v01x0y7hfa7rqob6rffg6e2p2wq-278qafb9ptpqtfebr0kyngi0b 192.168.191.6:2377

更多Docker相关教程见以下内容: 

Linux 下的 Docker 安装与使用  https://www.linuxidc.com/Linux/2018-06/152996.htm
CentOS 7安装Docker应用容器引擎 https://www.linuxidc.com/Linux/2018-06/152856.htm
CentOS 7.3环境安装Docker 18.03 https://www.linuxidc.com/Linux/2018-05/152356.htm
使用Docker分分钟启动常用应用  https://www.linuxidc.com/Linux/2017-04/142649.htm
CentOS 7使用Docker搭建GitLab服务器  https://www.linuxidc.com/Linux/2018-04/151725.htm
30分钟带你了解Docker  https://www.linuxidc.com/Linux/2018-08/153346.htm

Docker发布应用程序指南 https://www.linuxidc.com/Linux/2018-08/153405.htm

Docker 的详细介绍请点这里
Docker 的下载地址请点这里

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/a286284f5dfb7a43b97984784e30ffbc.html