文章目录
- 一、Ubuntu 20.04.6
- 1. 网卡和DNS配置
- 2. Docker安装
- 二、CentOS Linux 7.9
- 1. 网卡和DNS配置
- 2. Docker安装
- 三、Alibaba Cloud Linux 3
- 1. DNS配置
- 2. repo说明
- 3. Docker安装
- 四、验证是否安装成功
一、Ubuntu 20.04.6
1. 网卡和DNS配置
/etc/netplan 找到 *.yaml 文件
修改 IP地址和DNS
addresses: [192.168.1.11/24]
nameservers:
addresses: [119.29.29.29,8.8.8.8]
2. Docker安装
- 依次执行
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo systemctl daemon-reload
sudo systemctl restart docker
二、CentOS Linux 7.9
1. 网卡和DNS配置
/etc/sysconfig/network-scripts 找到 ifcfg-ens* 文件
修改 IP地址和DNS
IPADDR=192.168.1.111
DNS1=61.139.2.69
DNS2=8.8.8.8
2. Docker安装
- 依次执行
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum install wget
yum update -y
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum -y install docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
三、Alibaba Cloud Linux 3
1. DNS配置
- NetworkManager配置
vim /etc/NetworkManager/conf.d/90-dns-none.conf
- 编辑内容
[main]
dns=none
- 执行命令使配置生效
systemctl reload NetworkManager
- DNS配置
vim /etc/resolv.conf
- 编辑内容
nameserver 223.5.5.5
nameserver 8.8.8.8
- 执行命令锁定配置
chattr +i /etc/resolv.conf
- 重新编辑配置文件先解锁
chattr -i /etc/resolv.conf
2. repo说明
如果mirrors.cloud.aliyuncs.com不能访问,则将/etc/yum.repos.d下所有文件的
http://mirrors.cloud.aliyuncs.com改为https://mirrors.aliyun.com
然后运行
yum clean all && yum makecache
3. Docker安装
依次执行
yum install -y yum-utils
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache
dnf config-manager --add-repo=https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
dnf -y install dnf-plugin-releasever-adapter --repo alinux3-plus
dnf -y install docker-ce --nobest
systemctl start docker
systemctl enable docker
四、验证是否安装成功
运行
systemctl status docker
效果