为镜像添加SSH服务

一、基于commit命令创建

1.1 下载镜像

$docker pull ubuntu:18.04
$docker run -it ubuntu:18.04 bash

1.2 更新软件源

:/# apt-get update

1.3 添加国内源

:/# 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
:/# 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服务

相关推荐