1. 規(guī)劃節(jié)點
Docker部署節(jié)點規(guī)劃如下表所示:
IP | 主機名 | 節(jié)點 |
192.168.100.10 | master | Docker節(jié)點 |
2. 基礎(chǔ)準備
所有節(jié)點安裝CentOS7.9_2009系統(tǒng),并配置主機名和網(wǎng)卡。
配置主機名和網(wǎng)卡
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=1f637ed7-8149-4c10-b9ec-ef4e8ac4a489
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.10
NETMASK=255.255.255.0
GATEWAY=192.168.100.2
DNS1=8.8.8.8
[root@localhost ~]# hostnamectl set-hostname master
[root@localhost ~]# su
[root@master ~]# hostnamectl
Static hostname: master
Icon name: computer-vm
Chassis: vm
Machine ID: 9f42b0fc9dda47ff94338acf8052f2ef
Boot ID: 90afd45aef1b4c8b862038f2cb0fa1bb
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.el7.x86_64
Architecture: x86-64
[root@master ~]#
(一) 在線安裝docker
1.檢測、配置安裝環(huán)境
查看linux版本,是否符合>centos 7
[root@master ~]# uname -r
3.10.0-1160.el7.x86_64
查看網(wǎng)絡(luò)是否通暢
安裝gcc,gcc-c++編譯器
?
[root@master ~]# ping www.baidu.com
[root@master ~]# yum -y install gcc-c++
安裝device-mapper-persistent-data和lvm2工具
[root@master ~]# yum install yum-utils device-mapper-persistent-data lvm2
換阿里云的源
[root@master ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum 索引重建,提高安裝速度
[root@master ~]# yum makecache fast
安裝docker
[root@master ~]# yum install -y docker-ce docker-ce-cli containerd.io
啟動
[root@master ~]# systemctl start docker
檢測版本
運行hello-world
(二)離線安裝Docker
卸載Docker
[root@master ~]# yum remove docker-ce docker-ce-cli containerd.io
[root@master ~]# rm -rf /var/lib/docker/
1. 基礎(chǔ)環(huán)境配置
(1)配置YUM源
將提供的壓縮包Docker.tar.gz上傳至/root目錄并解壓。
[root@master ~]# tar -zxvf Docker.tar.gz
配置本地YUM源。
[root@master ~]# mkdir /opt/centos
[root@master ~]# mount /dev/sr0 /opt/centos/
mount: /dev/sr0 is write-protected, mounting read-only
[root@master ~]# mv /etc/yum.repos.d/* /media/
[root@master ~]# vi /etc/yum.repos.d/local.repo
[root@master ~]# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[Docker]
name=docker
baseurl=file:///root/Docker
gpgcheck=0
enabled=1
(2)配置防火墻及SELinux
配置防火墻及SELinux,示例代碼如下:
[root@master ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@master ~]# iptables -F
[root@master ~]# iptables -X
[root@master ~]# iptables -Z
[root@master ~]# iptables-save
# Generated by iptables-save v1.4.21 on Thu Mar 21 04:06:14 2024
*filter
:INPUT ACCEPT [20:1280]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [11:968]
COMMIT
# Completed on Thu Mar 21 04:06:14 2024
[root@master ~]# vi /etc/selinux/config
[root@master ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
(4)開啟路由轉(zhuǎn)發(fā)
[root@master ~]# cat >> /etc/sysctl.conf << EOF
> net.ipv4.ip_forward=1
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> EOF
[root@master ~]# modprobe br_netfilter
[root@master ~]# sysctl -p
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
2. Docker引擎安裝
(1)安裝依賴包
yum-utils提供了yum-config-manager的依賴包,device-mapper-persistent-data和lvm2are需要 devicemapper存儲驅(qū)動。
[root@master ~]# yum install -y yum-utils device-mapper-persistent-data
(2)安裝docker-ce
? ? 隨著Docker的不斷流行與發(fā)展,Docker組織也開啟了商業(yè)化之路,Docker從17.03版本之后分為CE (CommunityEdition)和EE(EnterpriseEdition)兩個版本。
? ? Docker EE專為企業(yè)的發(fā)展和IT團隊建立,為企業(yè)提供最安全的容器平臺,以應(yīng)用為中心的平臺,有專 門的團隊支持,可在經(jīng)過認證的操作系統(tǒng)和云提供商中使用,并可運行來自DockerStore的經(jīng)過認證的容器 和插件。
? ? Docker CE是免費的Docker產(chǎn)品的新名稱,Docker CE包含了完整的Docker平臺,非常適合開發(fā)人員 和運維團隊構(gòu)建容器APP。此處安裝指定版本的Docker CE。
[root@master ~]# yum install docker-ce docker-ce-cli containerd.io -y
3. 啟動Docker
啟動Docker并設(shè)置開機自啟。
[root@master ~]# systemctl daemon-reload
[root@master ~]# systemctl restart docker
[root@master ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
查看Docker的系統(tǒng)信息。文章來源:http://www.zghlxwxcb.cn/news/detail-843445.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-843445.html
到了這里,關(guān)于Docker引擎安裝的兩種方式的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!