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. 下 ...
随机推荐
- Hadoop启动之后jps没有NameNode节点
这是因为多次格式化namenode节点出现的问题 1.先运行stop-all.sh 2.删除原目录,即core-site.xml下配置的<name>hadoop.tmp.dir</n ...
- port 执行命令的封装和参数详解
下面代码摘自rebar_utils.erl -module(tt7). %-export([start/0]). -compile(export_all). -define(FAIL, abort() ...
- 【洛谷p1066】2^k进制数
(不会敲键盘惹qwq) 2^k进制数[传送门] 算法标签: (又是一个提高+省选-的题) 如果我说我没听懂你信吗 代码qwq: #include<iostream> #include< ...
- linux 基础命令,未完待续
1, cd 进入系统根目录 cd / 进入当前用户的主目录 cd ~ 进入当前目录的上一级目录 cd .. 跳转到指定目录,从根目录开始 cd /apps/ 2, pwd 查看当前工作目录的完整路径 ...
- 码云git使用五(创建远程分支和更新远程分支)
1.创建一个与远程分支没有关联的本地分支 2.从远程拉取到本地分支 3.创建远程分支() 4.搞定了.
- Python查看与安装
官网下载最新的版本 https://www.python.org mac系统,最近版本的os系统默认自带python 2.7,可以通过在终端输入python或python -V zhanyunjiu ...
- python二进制读写文件
#coding=gbk ''' Created on 2014-5-7 ''' import os.path inputPath = './input.txt' outPath = './out.tx ...
- Spring Boot + Jpa + Thymeleaf 增删改查示例
快速上手 配置文件 pom 包配置 pom 包里面添加 Jpa 和 Thymeleaf 的相关包引用 <dependency> <groupId>org.springframe ...
- oracle 导出某用户下的表
exp test/test@orcl owner=test file=E:/all.dmp
- Java易错题(1)
检查程序,是否存在问题,如果存在指出问题所在,如果不存在,说明输出结果. public class HelloB extends HelloA { public HelloB() { } { Syst ...