Docker创建支持ssh服务的容器和镜像
2016-09-19 13:46
891 查看
Docker创建支持ssh服务的容器和镜像
1. 这里使用的centos作为容器,所以首先下载centos的images
sudo docker pull centos
2. 下载后运行一个centos的容器,这里使用centos6作为我测试的容器
sudo docker run --name=centos-ssh -i -t centos:centos6 /bin/bash
3. 安装openssh-server服务软件包
yum install openssh-server
4. 编辑sshd的配置文件/etc/ssh/sshd_config,将其中UsePAM参数设置成“no”
5. 启动sshd服务
/etc/init.d/sshd start
6. 添加测试用户admin,密码admin
useradd admin
echo 'admin:admin' | chpasswd
7. 为了使新添加的用户可以运行sudo命令,需要安装sudo软件包,并将admin添加到sudoers里
yum install sudo <--安装sudo软件包
visudo <--编辑sudoers,添加下面的行到文件里
admin ALL=(ALL) ALL
8. 测试,做完上面工作之后,使用ifconfig来查看一下容器的ip,或者使用“sudo docker inspect ”查看,然后就可以在宿主机器上通过ssh admin@<ip>来访问新创建的docker容器了。
9. 如果想要把做好的支持ssh服务的容器作为一个docker的镜像,先退出容器,然后使用下面的命令来创建
sudo docker commit <container id> <image name>
1. 这里使用的centos作为容器,所以首先下载centos的images
sudo docker pull centos
2. 下载后运行一个centos的容器,这里使用centos6作为我测试的容器
sudo docker run --name=centos-ssh -i -t centos:centos6 /bin/bash
3. 安装openssh-server服务软件包
yum install openssh-server
4. 编辑sshd的配置文件/etc/ssh/sshd_config,将其中UsePAM参数设置成“no”
5. 启动sshd服务
/etc/init.d/sshd start
6. 添加测试用户admin,密码admin
useradd admin
echo 'admin:admin' | chpasswd
7. 为了使新添加的用户可以运行sudo命令,需要安装sudo软件包,并将admin添加到sudoers里
yum install sudo <--安装sudo软件包
visudo <--编辑sudoers,添加下面的行到文件里
admin ALL=(ALL) ALL
8. 测试,做完上面工作之后,使用ifconfig来查看一下容器的ip,或者使用“sudo docker inspect ”查看,然后就可以在宿主机器上通过ssh admin@<ip>来访问新创建的docker容器了。
9. 如果想要把做好的支持ssh服务的容器作为一个docker的镜像,先退出容器,然后使用下面的命令来创建
sudo docker commit <container id> <image name>
相关文章推荐
- 详解Docker创建支持ssh服务的容器和镜像
- Docker- 创建支持SSH服务的容器镜像
- Docker使用Dockerfile创建支持ssh服务自启动的容器镜像
- Docker使用Dockerfile创建支持ssh服务自启动的容器镜像
- 使用Dockerfile创建支持ssh服务自启动的容器镜像
- Docker创建支持ssh服务的容器和镜像
- Docker使用Dockerfile创建支持ssh服务自启动的容器镜像
- Docker创建支持ssh服务的容器和镜像
- Docker使用Dockerfile创建支持ssh服务自启动的容器镜像
- Docker创建支持ssh服务的容器和镜像
- Docker- 创建支持SSH服务的容器镜像
- Docker使用Dockerfile创建支持ssh服务自启动的容器镜像
- Docker创建支持ssh服务的容器和镜像
- Docker使用Dockerfile创建支持ssh服务自启动的容器镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像
- 使用Dockerfile构建支持ssh服务自启动的容器镜像
- Docker实战:使用Dockerfile创建带nginx服务并支持ssh的Centos Docker镜像
- <转>创建支持SSH服务的Docker镜像
- 创建支持SSH服务的Docker镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像