赞
踩
Docker要求Linux内核不低于 3.10 ,使用 CentOS 7及以上即可
uname -a 查看内核信息
Docker 分为 CE 和 EE 两大版本 我们安装CE社区版本即可
原先如果有安装可以使用下面命令卸载
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装 yum-utils
yum install -y yum-utils
[root@node01 ~]# yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Determining fastest mirrors
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/5): epel/7/x86_64/group_gz | 98 kB 00:00:00
(2/5): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00
(3/5): extras/7/x86_64/primary_db | 249 kB 00:00:00
(4/5): updates/7/x86_64/primary_db | 17 MB 00:00:01
(5/5): epel/7/x86_64/primary_db | 7.0 MB 00:00:01
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
设置docker镜像源,这里选择阿里云镜像
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@node01 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
#查看是否添加成功 [root@node01 yum.repos.d]# cat /etc/yum.repos.d/docker-ce.repo |grep aliyun baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/stable gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/stable gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/test gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/test gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/test gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/nightly gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/nightly gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/nightly gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
安装docker
这里需要等待一段时间
yum install -y docker-ce
[root@node01 yum.repos.d]# docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
这里还没有启动报一小段错,需要启动一下
启动docker
可以选择关闭防火墙,不关闭也没关系,后面搭建k8s还是建议关闭
systemctl stop firewalld
#禁止开开机启动
systemctl disable firewalld
查看状态
systemctl status firewalld
systemctl start docker
#开机自动启动
systemctl enable docker
再次查看version
[root@node01 ~]# docker version Client: Docker Engine - Community Version: 20.10.21 API version: 1.41 Go version: go1.18.7 Git commit: baeda1f Built: Tue Oct 25 18:04:24 2022 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.21 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 3056208 Built: Tue Oct 25 18:02:38 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.9 GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536f runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0
配置镜像加速
需要注册一个阿里云账号,用自己的,也可以用别人的。
注册地址
https://cr.console.aliyun.com/cn-beijing/instances
选择镜像工具->镜像加速器->选择对应版本 我这里选择centos
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://49w1xpkl.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。