ubuntu-docker入门到放弃(八)创建支持SSH服务的镜像
我们知道进入docker容器可以使用attach、exec等命令来操作和管理,但是如果需要远程登录并管理容器,就需要ssh服务的支持了。
1、基于commit命令创建
docker提供了commit命令,支持用户提交自己对容器的修改,并生成新的镜像。
格式:
#docker commit CONTAINER [REPOSITORY[:TAG]]
我们今天使用的ubuntu14.04系统来测试:
运行ubuntu14.04:
#docker run -dit ubuntu:14.04 /bin/bash
安装和配置ssh服务:
#apt-get update
#apt-get install openssh-server
#service ssh start
#netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3064/sshd
tcp6 0 0 :::22 :::* LISTEN 3064/ssh
可以看到,ssh服务已经起来了,端口为22.
创建一个启动ssh服务的脚本并添加可执行权限:
#vi /run.sh
内容:
#!/bin/bash
/usr/sbin/sshd -D 保存退出
#chmod /run.sh
退出容器,然后将刚刚的容器用docker commit 命令来保存为一个新的sshd:ubuntu镜像:
#docker commit f5614a29f767 sshd:ubuntu
sha256:f0fc45b72c9abb90e929a7557692f5fb9c3953426f4b13e14d16a9c3b5158a04
查看我们本地的images信息:
#docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sshd ubuntu f0fc45b72c9a seconds ago 243MB
ubuntu 16.04 a51debf7e1eb days ago 116MB
debian latest 4879790bd60d days ago 101MB
test ea2185f851a4 days ago 244MB
buile_repo/frist_image latest a209b4fcb225 days ago 244MB
10.30.234.212:/ubuntu14_ruby latest fd2e33845352 weeks ago 157MB
可以看到我们刚刚commit的带有sshd的image。
ubuntu-docker入门到放弃(八)创建支持SSH服务的镜像的更多相关文章
- 使用Dockerfile创建支持SSH服务的镜像
1.前面我们学习了使用Dockerfile,那接下来我们就用Dockerfile创建一个支持SSH服务的镜像. 2.首先创建一个目录ssh_centos [root@rocketmq-nameserv ...
- docker如何创建支持SSH服务的镜像
一般情况下,Linux系统管理员通过SSH服务来管理操作系统,但Docker的很多镜像是不带SSH服务的,那么我们怎样才能管理操作系统呢?在第一部分中我们介绍了一些进入容器的办法,比如用attach. ...
- Docker(2):使用Dockerfile创建支持SSH服务的镜像
1.创建工作目录 # mkdir sshd_ubuntu # ls 在其中,创建Dockerfile和run.sh文件 # cd sshd_ubuntu/ # touch Dockerfile run ...
- docker基于commit命令创建支持ssh服务的镜像
以centos为基础,目的使用ssh服务远程连接docker容器. 环境:宿主机centos7(宿主机ip地址为192.168.164.130),直接搜索docker的centos镜像,下载最新版本. ...
- 创建支持SSH服务的镜像
一.基于commit命令创建 docker commit CONTAINER [REPOSITORY [:TAG]] 1.使用ubuntu镜像创建一个容器 docker run -it ubuntu ...
- docker基于Dockerfile命令创建支持ssh服务的镜像
首先,创建一个sshd_centos工作目录: [root@localhost ~]# mkdir sshd_centos [root@localhost ~]# cd sshd_centos [ro ...
- Docker创建支持ssh服务的容器和镜像
原文链接:Docker创建支持ssh服务的容器和镜像 1. 这里使用的centos作为容器,所以首先下载centos的images # sudo docker pull centos 2. 下载后执行 ...
- Docker使用Dockerfile创建支持ssh服务自启动的容器镜像
原文链接:Docker使用Dockerfile创建支持ssh服务自启动的容器镜像 1. 首先创建一个Dockerfile文件.文件内容例如以下 # 选择一个已有的os镜像作为基础 FROM cento ...
- 创建支持ssh服务的docker容器和镜像
http://www.kongxx.info/blog/?p=57 1. 这里使用的centos作为容器,所以首先下载centos的imagessudo docker pull centos 2. 下 ...
随机推荐
- html缓存控制
- 树状DP HDU1520 Anniversary party
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1520 题意:职员之间有上下级关系,每个职员有自己的happy值,越高在派对上就越能炒热气氛.但是必须是 ...
- Tinkoff Internship Warmup Round 2018 and Codeforces Round #475 (Div. 1)D. Frequency of String
题意:有一个串s,n个串模式串t,问s的子串中长度最小的包含t k次的长度是多少 题解:把所有t建ac自动机,把s在ac自动机上匹配.保存每个模式串在s中出现的位置.这里由于t两两不同最多只有xsqr ...
- spring cloud(二)服务(注册)中心Eureka
Eureka是Netflix开源的一款提供服务注册和发现的产品,它提供了完整的Service Registry和Service Discovery实现.也是springcloud体系中最重要最核心的组 ...
- vue教程自学笔记(三)
五.Class与Style绑定 可以用v-bind用于class和style,表达式结果类型除了字符串,还可以是对象或数组. 1.绑定HTML Class 对象语法:给v-bind:class传递一个 ...
- Jumpserver跳板机的搭建和部署
1.需要搭云yum仓库wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 2. ...
- 演示stop暴力停止线程导致数据不一致的问题,但是有些有趣的发现 (2017-07-03 21:25)
如注释所言 /** * Created by weiwei22 on 17/7/3. * * 这里主要是为了演示stop导致的数据不一致的问题.stop会暴力的结束线程并释放锁,所以有可能在恰好写了一 ...
- mongoose的关联查询 :populate
mongoose关联查询从3.2版本开始支持 基本用法如下: var studentSchema = new Schema({ name:String, age:String, school:{ ty ...
- Kruskal算法(题目还是:畅通工程)
那还是先把题目丢出来,是HDU上的一道题 畅通工程 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- ios 审核未通过 相机相册权限问题
苹果提交审核被打回来 附加的说明如下: We noticed that your app requests the user’s consent to access their camera but ...