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.内 ...
随机推荐
- Kali 无法正常上网问题
有时候我们会突然发现我们的kali不能够正常上网,在终端使用ping 命令对其进行检查,显示网络不可达, 然后使用ifconfig,可以看到没有正在工作的网卡,只有localhost 接着使用ifco ...
- gcc编译基本用法~2
编译简单的 C 程序 C 语言经典的入门例子是 Hello World,下面是一示例代码: ;} 我们假定该代码存为文件‘hello.c’.要用 gcc 编译该文件,使用下面的命令: $ gcc -g ...
- 离线批量数据通道Tunnel的最佳实践及常见问题
基本介绍及应用场景 Tunnel是MaxCompute提供的离线批量数据通道服务,主要提供大批量离线数据上传和下载,仅提供每次批量大于等于64MB数据的场景,小批量流式数据场景请使用DataHub实时 ...
- Docker最全教程——从理论到实战(二)
上篇内容链接: https://www.cnblogs.com/codelove/p/10030439.html Docker和ASP.NET Core Docker 正在逐渐成为容器行业的事实标准, ...
- [转]gitlab配置通过smtp发送邮件(QQ exmail腾讯企业为例)
本文转自:http://www.fayfox.com/post/39.html 首先祭出官网文档链接:https://docs.gitlab.com/omnibus/settings/smtp.htm ...
- [android]android下apk的安装过程
/********************2016年4月23日更新********************************/ 知乎:有什么apk分析工具? 拿到了一个apk文件,怀疑不安全,在 ...
- C# 如何更改Word语言设置
一般在创建或者打开一个Word文档时,如果没有进行过特殊设置的话,系统默认的输入语言的是英语输入,但是为适应不同的办公环境,我们其实是需要对文字嵌入的语言进行切换的,因此,本文将介绍如何使用免费版组件 ...
- GNOME图形界面的基本操作
成功登录进入CentOS系统之后,我们首先看到的桌面就是GNOME图形界面,下面来看一下相关的基本操作. 个性化设置 1,设置屏幕分辨率 进入菜单 2,更换桌面背景 进入下面菜单. 选择一张背景图片, ...
- 熟悉常用的HBase操作,编写MapReduce作业
1. 以下关系型数据库中的表和数据,要求将其转换为适合于HBase存储的表并插入数据: 学生表(Student) 学号(S_No) 姓名(S_Name) 性别(S_Sex) 年龄(S_Age) 201 ...
- document.getElementById(), getElementsByname(),getElementsByClassName(),getElementsByTagName()方法表示什么以及其意义
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...