首页 > 代码库 > Dockefile CentOS SSH 服务的实现
Dockefile CentOS SSH 服务的实现
1, docker 安装
yum -y install docker-io
2, docker服务启动
service docker restart chkconfig docker on
3, docker 镜像下载
docker pull centos6
4, docker dockerfile SSH 实现
a) mkdir /data/docker/ssh -p
b) vim /data/docker/ssh/Dockerfile
FROM centos:centos6 MAINTAINER william "swq.499809608@hotmail.com" RUN yum install -y openssh-server sudo RUN sed -i ‘s/UsePAM yes/UsePAM no/g‘ /etc/ssh/sshd_config RUN useradd william RUN echo "william:william" | chpasswd RUN echo "william ALL=(ALL) ALL" >> /etc/sudoers RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key RUN mkdir /var/run/sshd EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"]
5, 生成docker 镜像
docker build -t centos6-bash-ssh ssh
6, 启动docker centos6-bash-ssh 镜像
docker run -i -t centos6-bash-ssh /bin/bash
7, 验证docker centos6-bash-ssh 镜像
[root@AthController53 sshd]# docker attach 7977c7fee355 bash-4.1# ifconfig eth0 Link encap:Ethernet HWaddr 6E:5A:DD:C2:57:F1 inet addr:172.17.0.10 Bcast:0.0.0.0 Mask:255.255.0.0 inet6 addr: fe80::6c5a:ddff:fec2:57f1/64 Scope:Link UP BROADCAST RUNNING MTU:1500 Metric:1 RX packets:350 errors:0 dropped:0 overruns:0 frame:0 TX packets:206 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:39054 (38.1 KiB) TX bytes:31757 (31.0 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) bash-4.1#
[root@AthController53 sshd]# ssh 172.17.0.10 root@172.17.0.10‘s password: Last login: Tue Nov 11 09:43:14 2014 from 172.17.42.1 -bash-4.1#
本文出自 “欢迎评论,欢迎点赞” 博客,请务必保留此出处http://swq499809608.blog.51cto.com/797714/1575592
Dockefile CentOS SSH 服务的实现
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。