docker 安装

 1.及其环境初始化

(1)防火墙,selinux

systemctl stop firewalld
systemctl disable firewalld

sed -i 's/SELIUX=enforcing/SELINUX=disabled/' /etc/selinux/config

(2)yum 源更新

如果虚拟机镜像是最小化安装,可以先下载下面插件

 yum install -y bash-completion vim wget expect net-tools nc nmap tree dos2unix htop iftop iotop unzip telnet sl psmisc nethogs glances bc ntpdate openldap-devel

然后更新

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 

清空缓存

yum clean all

生成新的缓存

yum makecache

2.docker安装准备

(1)docker必须安装centos7平台,内核版本不低于3.10

在centos7平台运行docker可能会遇到些警告,修改内核配置参数,打开内核转发功能

#写入

cat <<EOF > /etc/sysctl.d/docker.conf
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> net.ipv4.conf.default.rp_filter = 0
> net.ipv4.conf.all.rp_filter = 0
> net.ipv4.ip_forward=1
> EOF

modprobe br_netfilter

重新加载内核

sysctl -p /etc/sysctl.d/docker.conf

(2)利用yum快速安装docker

yum list docker-ce -y

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O/etc/yum.repos.d/docker-ce.repo

yum clean all

yum makecache

查看可用版本

yum list docker-ce --showduplicates | sort -r

 

删除docker

yum remove docker-ce.xxxxx

 

3 配置镜像加速器:用于加速镜像文件的下载

mkdir /etc/docker

vim /etc/docker/daemon.json

 

{
"registry-mirrors" : [
"https://8xpk5wnt.mirror.aliyuncs.com"
]
}

重新读取配置文件:

systemctl daemon-reload

重启

systemctl start docker

docker version

posted @ 2021-08-04 16:36  是暗夜星辰  阅读(144)  评论(0)    收藏  举报