1.
# 查看系统内核
[root@Link ~]# uname -r
3.10.0-1062.18.1.el7.x86_64
# 查看系统版本
[root@Link ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
2.安装
# 1.卸载旧的版本 Uninstall old versions
[root@Link ~]# yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 2.需要的安装包 Install using the repository
[root@Link ~]# yum install -y yum-utils
# 3.设置镜像的仓库 Set up the repository
# 默认是从国外的,建议不使用,较慢
[root@Link ~]# yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
# 推荐使用阿里云的,很快
[root@Link ~]# yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装容器之前,更新yum软件包索引。yum makecache fast
[root@Link ~]# yum makecache
# 4.安装容器相关的 Install Docker Engine
# docker-ce(社区版)docker-ee(企业版)
[root@Link ~]# yum install docker-ce docker-ce-cli containerd.io
# 5.启动docker
[root@Link ~]# systemctl start docker
# 6.查看是否安装成功
[root@Link ~]# docker version
3.测试
# 7.测试hello-world
[root@Link ~]# docker run hello-world
# 8.查看一下,下载的这个hello-world镜像
[root@Link ~]# docker images
4.卸载
# 1.卸载依赖 Uninstall Docker Engine
[root@Link ~]# yum remove docker-ce docker-ce-cli containerd.io
# 2.删除资源
# /var/lib/docker 是docker的默认工作路径
[root@Link ~]# rm -rf /var/lib/docker
[root@Link ~]# rm -rf /var/lib/containerd