docker 安装 --在线方式

发布于:2025-02-12 ⋅ 阅读:(19) ⋅ 点赞:(0)

第一步:

#!/bin/bash
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
sudo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sudo sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/epel.repo
curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 更新缓存

sudo clean all
sudo yum makecache

apt-get install -y docker-ce-20.10.24-3.el7 docker-ce-rootless-extras-20.10.24-3.el7 net-tools nmap-ncat ethtool
 
systemctl start docker
systemctl daemon-reload

systemctl restart docker

systemctl enable docker

systemctl enable containerd.service
systemctl restart docker.socket

timedatectl set-timezone Asia/Shanghai
echo "Asia/shanghai" > /etc/timezone
date

useradd -g docker jiayin
echo 'Jiay@2023'| passwd --stdin jiayin

usermod -aG docker jiayin
chown root:docker /var/run/docker.sock

mkdir /data
chown -R jiayin:docker /data

su jiayin
docker info

modprobe ip_vs

============================
第二步:

开启Docker Swarm集群
docker swarm init --cert-expiry 8544h                 端口:2377
docker swarm join-token manager

第三步:

创建cloud网络(相当于物理交换机)
注意会使用10.10网段,服务器网卡最好不是10.10,否则可能出问题
docker network create -d overlay --attachable --subnet 10.10.10.0/24 cloud
docker network ls
docker network inspect cloud