docker 搭建centos6.5 ssh 服务出现的问题
2017-02-22 00:00
756 查看
环境: host Machine: centos7 x86-64
docker : 1.13.1
image name : mycentos6.5
一、 准备工作中出现的问题:
docker 启动centos6.5 创建 一个容器 :
这样 则进入 centos6.5 中. 出现的问题:
iptables 无法使用: eg: #iptables -L 出现类似的问题(来源于其他):
Table: filter
FATAL: Could not load /lib/modules/2.6.32-358.el6.x86_64/modules.dep: No such file or directory
iptables v1.4.7: can't initialize iptables table `filter': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
Table: nat
FATAL: Could not load /lib/modules/2.6.32-358.el6.x86_64/modules.dep: No such file or directory
iptables v1.4.7: can't initialize iptables table ‘nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded
docker : 1.13.1
image name : mycentos6.5
一、 准备工作中出现的问题:
docker 启动centos6.5 创建 一个容器 :
docker run -it --name centos6.5 mycentos6.5Image /bin/bash
这样 则进入 centos6.5 中. 出现的问题:
iptables 无法使用: eg: #iptables -L 出现类似的问题(来源于其他):
Table: filter
FATAL: Could not load /lib/modules/2.6.32-358.el6.x86_64/modules.dep: No such file or directory
iptables v1.4.7: can't initialize iptables table `filter': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.
Table: nat
FATAL: Could not load /lib/modules/2.6.32-358.el6.x86_64/modules.dep: No such file or directory
iptables v1.4.7: can't initialize iptables table ‘nat': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded
solve: 由于容器创建容器为了安全, 将访问设备的权限默认禁止, 因此 我们使用iptables 或者mount 时 出现不可访问的现象, **解决**: 在docker创建容器时, 添加`--priviliged` 开放所有权限,像操作实体机一样,当然也有其他方式,指定设备的访问权限,具体可以看看--cap-add。 添加后的代码: `docker run -it --privileged --name centos6.5 mycentos6.5 /bin/bash` 重新进入系统内, 就可以使用iptables了。 2 . 在想要给系统重新设置密码时: paawd: 出现问题: `:s0 is not authorized to change the password of root`(来源于其他): 这可能是由于selinux的问题(这个也不太懂 ,自行google ^ . ^):大致是由于在容器内创建用户名或者密码时,由于selinux所设置的最小权限原则导致无法顺利执行: **解决方法**: 1. 进入物理机 : # sestatus `SELinux status: enabled` 2. 修改 /etc/selinux/config `SELINUX=disabled` 3. 保存并退出 4. 重启 5. 执行: #getenforce `Disabled` 再次进入则就可以使用passwd 修改密码了. **详情可以在下面链接中查看:** 二: 搭建sshd 服务: a.) 创建容器并运行: ``` dokcer run -it --privileged --name centos6.5 -p hostIp:hostPort:dockerPort mycentos6.5Image /bin/bash ``` b.) 关闭iptables : (保证端口能够使用,不会被限制) ``` #service iptables stop ``` c.) 重新键入密码: ``` #passwd ``` ( eg : abc123) d.) 启动sshd 服务: ``` #service sshd start ``` 三: ssh 远程访问: linux : ```#ssh -p hostPort dockerUsername(eg: root)@hostIp``` ----> Enter: ---> input passwd of dockerUsername(as above:abc123) . windows: 使用putty 填入对应的hostip 和hostport 点击登陆 然后输入用户名的密码即可。 note: 若contain 重新启动, 需要重新启动sshd 服务, 或者直接将 启动sshd服务设置成开机启动。 参考链接: selinux关闭: http://linuxys.blogspot.com/2014/12/solved-lxc-not-authorized-to-change.html docker privileged的介绍: http://ikarishinjieva.github.io/tachikoma-blog/post/2014-07-10-docker-some-error/
相关文章推荐
- 关于腾讯云centos 6.5服务器镜像搭建出现的tomcat异常问题解决
- CentOS6.5上搭建Docker服务
- 关于用Myeclipse搭建ssh后出现there is no action mapped for namespace / and action …问题
- Centos 6.5上构建Git Lab服务及问题总结
- CentOS 6.5上尝试docker遇到的几个问题
- 在阿里云centos6.5系统上用docker搭建php环境的失败过程
- 搭建ssh出现问题Cannot find class [org.apache.commons.dbcp.BasicDataSource]出异常
- 【原创】windows通过ssh服务远程登录centos6.5
- 解决在CentOS6.5下安装OpenStack(Icehouse版本 )出现的glance服务无法正常工作的问题
- CentOS6.5使用 Docker 搭建 Java Web 运行环境
- centos 6.5 升级python到python 2.7.6出现的问题及解决方法汇总[经常更新]
- Centos搭建php+nginx+mysql+mongo出现的问题及解决方法
- centos6.5 安装stardict 出现问题 [Errno 256] No more mirrors to try
- Centos6.5 搭建基于 SSH协议 Git Server 服务器
- LAMP环境搭建过程中出现的问题——基于VM虚拟CentOS-5.6
- CentOS6.5 搭建NTP服务
- 基于CentOS6.5进行IPA服务的搭建――客户端配置
- 基于CentOS 6.5操作系统搭建MongoDB服务