Vultr CentOS 7 安装 Docker
前言
最近在梳理公司的架构,想用 VPS 先做一些测试,然后就开始踩坑了!我用 Vultr 新买了个 VPS。
安装的 CentOS 版本:
[root@dbn-seattle ~]# cat /etc/redhat-release CentOS Linux release (Core)
安装
先安装 Nginx,图方便,用了个自动脚本:
wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --nginx_option 1
安装 Nginx 成功,重启服务器,连接 SSH。
再安装 Docker:
# 移除旧版本的 Docker yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine # 安装 Docker 依赖 yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加源 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo # 更新 yum 缓存 yum makecache fast # 安装 Docker-CE yum install -y docker-ce # 开启 Docker systemctl start docker # 安装 Docker Compose curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose # Docker 和 Swarm 相关防火墙配置 systemctl status firewalld systemctl start firewalld firewall-cmd --add-port=9010/tcp --permanent firewall-cmd --add-port=9020/tcp --permanentfirewall-cmd --add-port=443/tcp --permanent firewall-cmd --add-port=80/tcp --permanent firewall-cmd --add-port=80/udp --permanentfirewall-cmd --add-port=22/tcp --permanent firewall-cmd --add-port=22/udp --permanent firewall-cmd --reload systemctl restart docker # 开机自启动 systemctl enable firewalld systemctl enable docker
一顿操作下来,执行顺利,无任何差错 Perfect!!
# 这里说明一下如果开始 firewalld 服务被锁定:Unit is masked # 需要先解除锁定,然后才能开放端口 systemctl unmask firewalld
重启的悲剧
Docker 安装成功后,只要重启了 VPS(不重启什么问题都没有),就会出现问题: SSH 连接不上了。
我重新安装了四遍才定位到是由于安装 Docker 重启导致 SSH 连接不上。前两次操作较多,没有定位到问题,期间我还升级了一下配置!!
尝试过的解决方案:
- 万能重启大法:无效,依然连接不上 SSH。
- IP 被河蟹了?TCP 阻断了?
- 国内工具扫描 22 端口:关闭。国外工具扫描 22 端口:关闭。
- 国内 Ping :不通。国外 Ping :不通。
- 由此断定是服务器出现问题了。
- 尝试在安装完毕后关闭防火墙:无效,依然连接不上 SSH。
- 厂商有问题?我尝试切换机房,然而问题再次出现了。
至此我就有点凌乱了,我反复确认了下自己操作的步骤,没有问题啊!得了,去网上找答案,爬着梯子就开始逛各个论坛,最后我在 segmentfault 发现了一个问答:参考资料①,然后我看的了这个博文:参考资料②,最后找到了 Vultr 的官方文档:参考资料③。
解决问题
对于 CentOS 7 实例,Docker 团队和 RHEL 团队提供 Selinux 支持。它已在 Vultr 一键式应用程序上禁用,但可以通过编辑 /etc/selinux/config 文件再次启用。
Fully securing a system that runs containers is an involved task. This task includes minimizing the attack surface on the Docker daemon. For a system that intends to run containers comparable to how a normal system would run binary apps, it is not as much of a concern. But for multi-tenant container configurations, or container configurations that need isolation (such as for credit card processing), securing the Docker daemon is more important.
至此我重置了 VPS ,运行命令:
[root@dbn-seattle ~]# getenforce Disabled
看到了 Selinux 的初始状态是禁止的状态。然后我安装 Docker ,安装完成后我再次运行命令:
[root@dbn-seattle ~]# getenforce Permissive
这里发现 Selinux 打开了,我们需要手动关闭下:
[root@dbn-seattle ~]# vim /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
SELINUX 修改成 disabled ,然后重启 VPS ,一切正常!!!
参考资料
① https://segmentfault.com/q/1010000015306843/a-1020000016431863
② https://hunterx.xyz/install-docker-on-vultr-centos-vps.html
③ https://www.vultr.com/docs/one-click-docker
Vultr CentOS 7 安装 Docker的更多相关文章
- CentOS 7 安装 Docker
CentOS 7 安装 Docker 这里介绍 ContOS 7 的安装 docker V1.2+,包括阿里云加速 docker 镜像下载的设置,这对提升使用 docker 体验至关重要.其他系统安装 ...
- 在RedHat/CentOS下安装Docker(不升级内核)
由于内核版本问题,最初仅Ubuntu可以较好的支持Docker.不过,由于RedHat系列OS(REHL.CentOS)是目前主流的Linux服务器操作系统,所以令RedHat系列OS支持Docker ...
- 简单介绍一下在CentOS上安装Docker。
简单介绍一下在CentOS上安装Docker. 前置条件: 64-bit 系统 kernel 3.10+ 1.检查内核版本,返回的值大于3.10即可. $ uname -r 2.使用 sudo 或 r ...
- Centos 下面安装 docker
试过了虚拟机VM ,今天尝试在虚拟机centos 中安装 docker ,入门是看的阮一峰的http://www.ruanyifeng.com/blog/2018/02/docker-tutorial ...
- docker学习之路-centos下安装docker
前言 我要在云服务器上做一个asp.net core的webapi应用,使用docker来部署应用,中间用到的任何组件包括nginx和sqlserver 2017都是用docker来装载运行,所以,这 ...
- Centos下安装Docker,并配置国内docker源
Centos下安装Docker 替换为国内的yum源(可选): mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.re ...
- Docker学习笔记之-在CentOS中安装Docker
上一节演示了如何 通过Xshell连接CentOS服务,链接:Docker学习笔记之-通过Xshell连接 CentOS服务 本节将演示 如何在CentOS中安装 Docker 第一步:更新系统包到最 ...
- CentOS 7 安装Docker
1.安装前检查: a.内核版本 uname -a b.检查Device Mapper ls -l /sys/class/misc/device-mapper 2.安装Docker: a.更新系统包到最 ...
- CentOS 7安装Docker
在虚拟机CentOS 7上安装Docker ## 零:检查前提条件: 在Red Hat 和Red Hat系列的Linux发行版中,安装Docker所需的前提提交并不多. ### 1.内 ...
随机推荐
- ssh-login 一键密码加密登录工具
ssh-login 1. Feature 管理多个帐号,每个帐号一个易记的 tip name,支持 tab 进行 tip name 补全,一键 ssh 登录 密码 AES 加密,密文存储密码,且只需要 ...
- Java架构师趣谈Hbase之宏观架构
相关文章 五分钟轻松了解Hbase列式存储 Hbase给初学者的“下马威” Hbase王国游记之:Hbase客户端API初体验
- kubernetes学习14—Dashboard搭建和认证
本文收录在容器技术学习系列文章总目录 一.介绍 Kubernetes Dashboard是Kubernetes集群的基于Web的通用UI.它允许用户管理在群集中运行的应用程序并对其进行故障排除,以及管 ...
- [三]JavaIO之IO体系类整体设计思路 流的概念以及四大基础分类
从本文开始,将正式进入JavaIO的简介 在继续javaIO系列的文章之前 可以过去看一下 本人博客上的设计模式中的 适配器模式和装饰器模式 这会对接下来的阅读大有帮助 本文是从逻辑上介绍整个的J ...
- 适用于app.config与web.config的ConfigUtil读写工具类
之前文章:<两种读写配置文件的方案(app.config与web.config通用)>,现在重新整理一个更完善的版本,增加批量读写以及指定配置文件路径,代码如下: using System ...
- 用户及用户组管理(week1_day4)--技术流ken
本节内容 useradd userdel usermod groupadd groupdel 用户管理 为什么需要有用户? 1. linux是一个多用户系统 2. 权限管理(权限最小化) 用户:存在的 ...
- 【.NET Core项目实战-统一认证平台】第十六章 网关篇-Ocelot集成RPC服务
[.NET Core项目实战-统一认证平台]开篇及目录索引 一.什么是RPC RPC是"远程调用(Remote Procedure Call)"的一个名称的缩写,并不是任何规范化的 ...
- 第44章 添加新协议 - Identity Server 4 中文文档(v1.0.0)
除了对OpenID Connect和OAuth 2.0的内置支持之外,IdentityServer4还允许添加对其他协议的支持. 您可以将这些附加协议端点添加为中间件或使用例如MVC控制器.在这两种情 ...
- [转]【翻译】在Visual Studio中使用Asp.Net Core MVC创建你的第一个Web API应用(一)
本文转自:https://www.cnblogs.com/inday/p/6288707.html HTTP is not just for serving up web pages. It’s al ...
- Spring boot入门(二):Spring boot集成MySql,Mybatis和PageHelper插件
上一篇文章,写了如何搭建一个简单的Spring boot项目,本篇是接着上一篇文章写得:Spring boot入门:快速搭建Spring boot项目(一),主要是spring boot集成mybat ...