在线安装
安装docker
yum install -y yum-utils device-mapper-persistent-data lvm2
#yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce
# 开机自启动
systemctl start docker
systemctl enable docker
查看docker服务状态
systemctl status docker
安装成功
离线安装
# 安装依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 libseccomp
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 下载安装包
yumdownloader --resolve docker-ce docker-ce-cli containerd.io
# 打包安装包
tar cf docker-ce.offline.tar *.rpm
# 上传到服务器并解压后, 安装离线docker
sudo rpm -ivh --replacefiles --replacepkgs *.rpm --nodeps --force
# 开机自启动
systemctl start docker
systemctl enable docker
修改docker的仓库
vi /etc/docker/daemon.json
{
"registry-mirrors": [
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com"
]
}
systemctl disable firewalld
systemctl stop firewalld
setenforce 0
vi /etc/selinux/config
# 修改 SELINUX=disabled
# 删除内容
swapoff -a
vi /etc/fstab
# 注释掉其中的 swap 一行
vi /etc/sysctl.conf
# 修改 vm.swappiness 的修改为 0
# vm.swappiness=0
# 使配置生效
sysctl -p
|