为镜像添加SSH服务
Posted tz90
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为镜像添加SSH服务相关的知识,希望对你有一定的参考价值。
一、基于commit命令创建
1.1 下载镜像
$docker pull ubuntu:18.04 $docker run -it ubuntu:18.04 bash
1.2 更新软件源
root@b1c8b932403e:/# apt-get update
1.3 添加国内源
root@b1c8b932403e:/# vi /etc/apt/sources.list.d/aliyun.list #添加如下内容 deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe root@b1c8b932403e:/# apt-get update
添加路由
Route add -net 192.168.0.0/24 gw 192.168.0.1
Route add -host 192.168.0.1 dev 192.168.0.1
删除路由
Route del -net 192.168.0.0/24 gw 192.168.0.1
查看容器IP
docker inspect mycentos2
docker inspect --format=‘{{.NetworkSettings.IPAddress}}‘ mycentos2
docker启动报错
删除/etc/docker/daemon.json文件
https://www.cnblogs.com/cocowool/p/docker_daemon_log_driver.html
碰到点问题,先记录一下,待会在整理
1.4 安装配置SSH服务
以上是关于为镜像添加SSH服务的主要内容,如果未能解决你的问题,请参考以下文章
10.Docker技术入门与实战 --- 为镜像添加SSH服务