系统信息
输入uname -r查看系统内核信息。如下:文章源自随机的未知-https://sjdwz.com/11161.html
[root@ls ~]# uname -r 3.10.0-1160.41.1.el7.x86_64
系统内核是3.10以上文章源自随机的未知-https://sjdwz.com/11161.html
查看系统环境信息文章源自随机的未知-https://sjdwz.com/11161.html
输入**cat /etc/os-release **查看系统版本信息文章源自随机的未知-https://sjdwz.com/11161.html
[root@ls ~]# 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"
系统版本是centos7文章源自随机的未知-https://sjdwz.com/11161.html
官网
进入docker官网 docker官网文章源自随机的未知-https://sjdwz.com/11161.html
链接为:https://www.docker.com/文章源自随机的未知-https://sjdwz.com/11161.html
将鼠标放到Developers上,可以看到如下菜单文章源自随机的未知-https://sjdwz.com/11161.html
点击docs文章源自随机的未知-https://sjdwz.com/11161.html
进入如下界面,并点击**Download and Install **文章源自随机的未知-https://sjdwz.com/11161.html
因为我们是Linux环境,所以我们点击Docker for Linux文章源自随机的未知-https://sjdwz.com/11161.html
点击CentOS文章源自随机的未知-https://sjdwz.com/11161.html
安装
卸载docker
如果你之前有安装过docker,需要先进行卸载,输入如下命令文章源自随机的未知-https://sjdwz.com/11161.html
yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine

安装所需安装包
本文介绍使用仓库进行安装,需要先安装需要的package文章源自随机的未知-https://sjdwz.com/11161.html
yum install -y yum-utils

设置镜像仓库
官方给的设置仓库命令如下:文章源自随机的未知-https://sjdwz.com/11161.html
yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
但是这是国外的仓库,比较慢。文章源自随机的未知-https://sjdwz.com/11161.html
我们使用国内的阿里云仓库,命令如下:文章源自随机的未知-https://sjdwz.com/11161.html
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新yum包索引
安装之前更新一下yum包的索引文章源自随机的未知-https://sjdwz.com/11161.html
输入如下命令文章源自随机的未知-https://sjdwz.com/11161.html
yum makecache fast

安装docker
完成上述步骤后,就可以进行安装了。输入如下命令文章源自随机的未知-https://sjdwz.com/11161.html
yum install docker-ce docker-ce-cli containerd.io
docker-ce表示社区版;文章源自随机的未知-https://sjdwz.com/11161.html
出现如上提示,输入y回车。文章源自随机的未知-https://sjdwz.com/11161.html
输入docker version查看是否安装成功文章源自随机的未知-https://sjdwz.com/11161.html
启动
输入如下命令启动docker文章源自随机的未知-https://sjdwz.com/11161.html
systemctl start docker
没有提示,悄无声息得就被启动了。文章源自随机的未知-https://sjdwz.com/11161.html
再次输入docker version;文章源自随机的未知-https://sjdwz.com/11161.html
Hello World
我们在学习编程的时候都会有一个小项目来进行上手,那就是Hello World。我们也来运行下docker的Hello World吧。文章源自随机的未知-https://sjdwz.com/11161.html
测试Hello World
输入如下命令文章源自随机的未知-https://sjdwz.com/11161.html
docker run hello-world

上面的提示内容是:在本地没有找到hello-world镜像,然后去仓库拉取镜像,最后运行hello-world。文章源自随机的未知-https://sjdwz.com/11161.html
查看Hello World镜像
输入如下命令查看镜像文章源自随机的未知-https://sjdwz.com/11161.html
docker images

最后
以上就是docker安装的全部内容了。如果本文对你有帮助,欢迎点赞,转发,收藏啊。文章源自随机的未知-https://sjdwz.com/11161.html