CentOS 7.6.1810
确定centos版本大于7,docker引擎仅支持centos7以上版本。
cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
这里采用yum安装的方式,如无外网,可下载rpm包手动安装。
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装gcc
yum -y install gcc gcc-c++
安装需要的软件包
yum -y install yum-utils
这里设置为国内阿里云仓库,速度更快。
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
查看/etc/yum.repos.d/文件夹会发现多了一个docker-ce.repo文件
ll /etc/yum.repos.d/
-rw-r--r-- 1 root root 230 Jan 10 21:31 CentOS-Epel.repo
yum makecache fast
yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
执行后可以看到安装了如下包:
Installed:
containerd.io.x86_64 0:1.6.16-3.1.el7 docker-buildx-plugin.x86_64 0:0.10.2-1.el7 docker-ce.x86_64 3:23.0.1-1.el7
docker-ce-cli.x86_64 1:23.0.1-1.el7 docker-compose-plugin.x86_64 0:2.16.0-1.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.2-1.911c772.el7_8
docker-ce-rootless-extras.x86_64 0:23.0.1-1.el7 docker-scan-plugin.x86_64 0:0.23.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libseccomp.x86_64 0:2.3.1-4.el7
libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7
setools-libs.x86_64 0:3.3.8-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
systemctl start docker
systemctl status docker
ps -ef |grep docker
root 10495 1 1 11:53 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 10660 29223 0 11:54 pts/0 00:00:00 grep --color=auto docker
docker version
docker run hello-word
显示如下信息代表docker安装成功
Hello from Docker!
This message shows that your installation appears to be working correctly.
停止docker
systemctl stop docker
卸载docker
yum remove docker-ce docker-ce-cli containerd.io
删除相关目录
rm -rf /etc/docker
rm -rf /run/docker
rm -rf /var/lib/dockershim
rm -rf /var/lib/docker
rm -rf /var/lib/containerd