docker的安装

安装docker

使用CentOS7及以上版本

cat /etc/redhat-release
(查看Redhat系的Linux版本)

一、准备安装环境

1、配置网络

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 
BOOTPROTO=static 
ONBOOT=yes 
IPADDR=192.168.88.101 
NETMASK=255.255.255.0 
GATEWAY=192.168.88.2 
DNS1=8.8.8.8

[root@localhost ~]# systemctl restart network
进入配置文件修改后重启网络

2、关闭防火墙和selinux

[root@localhost ~]# systemctl disable firewalld 
[root@localhost ~]# systemctl stop firewalld 

[root@localhost ~]# setenforce 0
临时关闭selinux

3、安装必要的环境和包

[root@localhost ~]# yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

# 图形化安装所需要的包
[root@localhost ~]# yum install -y yum-utils

4、设置为阿里的镜像仓库源 更新yum源

[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo  http://mirrors.aliyun.com/repo/Centos-7.repo
    
1)
[root@localhost ~]# yum-config-manager \
	--add-repo \
	http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  # 阿里云

2)
[root@localhost ~]# yum-config-manager \
    --add-repo \
    https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo  #清华大学云

# 任选一个云即可

5、查看当前版本,有显示就卸载依赖包

[root@localhost ~]# docker version 
[root@localhost ~]# yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

6、安装docker-ce

#安装docker
[root@localhost ~]# yum -y install docker-ce docker-ce-cli containerd.io

#查看当前版本
[root@ localhost ~]# docker version

#启动docker
[root@localhost ~]# systemctl restart docker


# 修改daemon配置文件/etc/docker/daemon.json来使用加速器
[root@localhost ~]# mkdir -p /etc/docker
[root@localhost ~]# tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://nxwgbmaq.mirror.aliyuncs.com"]
}
EOF
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
posted @ 2022-03-30 17:07  陽YANG  阅读(74)  评论(0编辑  收藏  举报