Loading

Docker安装

centos7 安装docker
升级内核版本以支持overlay2
使用uname -sr查看内核版本【一般为3.x或者4.x】
centos7升级内核命令如下:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org \ && rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm \ && yum clean all \ && yum --enablerepo=elrepo-kernel install kernel-ml -y \ && grub2-set-default 0
升级完内核需要重启一下

# 查看Linux是否加载了overlay模块
lsmod |grep over
# 如果有返回则说明已经加载
# 如果确定内核是最新那么可以执行
modinfo overlay
# 此处应该有类似/lib/modules/4.10.4-1.el7.elrepo.x86_64/kernel/fs/overlayfs/overlay.ko
# 最后我们添加overlay模块即可
modprobe overlay

使用docker仓库进行安装:
1、安装所需要的软件包
sudo yum install -y yum-utils
2、使用docker仓库进行安装,设置阿里云的源

sudo yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装 Docker Engine-Community
sudo yum install docker-ce docker-ce-cli containerd.io
如果提示您接受 GPG 密钥,请选是。
要安装特定版本的 Docker Engine-Community,请在存储库中列出可用版本,然后选择并安装:

yum list docker-ce --showduplicates | sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
 * elrepo: mirrors.tuna.tsinghua.edu.cn
docker-ce.x86_64            3:20.10.1-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.1-3.el7                    @docker-ce-stable
docker-ce.x86_64            3:20.10.0-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.9-3.el7                    docker-ce-stable 
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

启动docker sudo systemctl start docker
运行hello world sudo docker run hello-world

posted @ 2021-03-05 16:50  _bwang  阅读(85)  评论(0编辑  收藏  举报