
Dockr CE在Centos 7上的安装部署
发布日期:2021-05-10 10:10:24
浏览次数:18
分类:精选文章
本文共 6152 字,大约阅读时间需要 20 分钟。
官方文档:https://docs.docker.com/install/linux/docker-ce/centos/
1. 系统环境
[root@linux-node2 ~]# cat /etc/redhat-release CentOS Linux release 7.1.1503 (Core) [root@linux-node2 ~]# uname -r 3.10.0-229.el7.x86_64 [root@linux-node2 ~]# getenforce Disabled [root@linux-node2 ~]# systemctl status firewalld firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled) Active: inactive (dead)
2. 卸载旧的版本
[root@linux-node2 ~]# yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-eng
3. 安装Docker CE
3.1 通过资源库安装
3.1.1 安装所需要的包。
yum-utils提供了yum-config-manager实用程序,devicemapper存储驱动程序需要设备-mapper-persistent-data和lvm2。
yum install -y yum-utils
3.1.2 添加安装所需要的官方源。
#设置镜像 yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo#这里我们使用阿里云的 yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo#这里我们使用腾讯云的wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.reposudo sed -i 's+download.docker.com+mirrors.cloud.tencent.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo#更新软件包索引 yum makecache fast
3.1.3 安装Docker CE
a 安装Docker CE的最新版本
#docker-ce 社区版 ee 企业版 yum install -y docker-ce docker-ce-cli containerd.io
b 安装Docker CE的指定版本
yum list docker-ce --showduplicates | sort -r docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable #返回的列表取决于启用了哪些存储库,并且特定于您的CentOS版本 yum install docker-ce-18.06.1.ce #yum install docker-ce-
3.1.4 启动docker
#启动docker systemctl start docker #通过运行hello-world镜像来验证docker是否正确安装。 #这个命令下载一个测试映像并在容器中运行它。当容器运行时,它打印一条信息消息并退出。 docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world d1725b59e92d: Pull complete Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
3.2 通过RPM包安装
3.2.1 下载Docker CE的RPM包
访问https://download.docker.com/linux/centos/7/x86_64/stable/Packages/,下载您想要安装的Docker版本的.rpm文件。
3.2.2 安装Docker CE
yum install /path/to/package.rpm
3.2.3 启动docker
#启动docker systemctl start docker #通过运行hello-world镜像来验证docker是否正确安装。 #这个命令下载一个测试映像并在容器中运行它。当容器运行时,它打印一条信息消息并退出。 docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world d1725b59e92d: Pull complete Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/#查看下载的hello-world镜像[root@VM-16-11-centos ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEhello-world latest d1165f221234 7 weeks ago 13.3kB
4. 了解卸载Docker CE
#卸载依赖 yum remove docker-ce docker-ce-cli containerd.io #删除主机上所有镜像、容器和卷 rm -rf /var/lib/docker rm -rf /var/lib/containerd
配置镜像加速
cat > /etc/docker/daemon.json << EOF{"registry-mirrors": ["https://mirror.ccs.tencentyun.com" ]}EOFsystemctl daemon-reloadsystemctl restart docker
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2025年04月17日 12时02分40秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
input type="checkbox" 样式美化
2021-05-10
【Java】 # 对于日期Date类的相关操作
2021-05-10
【Java】 # (1)java语言实现正则表达式的简单应用(2)常用的正则表达式
2021-05-10
【JS】 # js获取当前日期,比较日期大小
2021-05-10
【JavaLearn】 # 培训(一)—— JavaSE查漏补缺
2021-05-10
SpringBoot找不到@EnableRety注解
2021-05-10
值传递和地址传递
2021-05-10
MyBatis的入门知识
2021-05-10
for循环控制
2021-05-10
IDEA常用快捷键
2021-05-10
深拷贝与浅拷贝
2021-05-10
RegExp:正则表达式对象 || Global对象
2021-05-10
JQuery 基础 || 目前 jQuery 有三个大版本||JQuery快速入门
2021-05-10
Vue指令之v-model和双向数据绑定
2021-05-10
简易计算器案例
2021-05-10
在Vue中使用样式——使用内联样式
2021-05-10
Hello World探究
2021-05-10
YAML语法
2021-05-10
@pathVariable 映射URL绑定的占位符
2021-05-10
测试ModelAttribute注解
2021-05-10