Sign inSign up

aaron8/ubuntu

By aaron8

•Updated about 4 years ago

Ubuntu

Image
0

115

aaron8/ubuntu repository overview

⁠开始部署

docker run --name ubuntu -t -i -d -p 2222:22 aaron8/ubuntu:20.04
参数: –name 指定生成的容器的名称
-i: 以交互模式运行容器,保证容器中STDIN是开启的。通常与 -t 同时使用
-t: 为容器重新分配一个伪tty终端,通常与 -i 同时使用
-d: 后台运行容器,并返回容器ID
-p:可以指定要映射的IP和端口,但是在一个指定端口上只可以绑定一个容器
支持的格式有 hostPort:containerPort、ip:hostPort:containerPort、 ip::containerPort
ubuntu 则是镜像名称,镜像ID也可以的

⁠安装ssh服务

1、进入容器终端安装ssh服务
docker exec -t -i ubuntu /bin/bash

2、执行更新
国内VPS换阿里源
sed -i 's/archive\.ubuntu\.com/mirrors.aliyun.com/g' /etc/apt/sources.list

apt-get update

3、安装ssh-client、ssh-server
apt-get install vim openssh-server

//安装完成后,先启动服务
/etc/init.d/ssh start

编辑sshd_config文件
vim /etc/ssh/sshd_config
去掉前面#生效
PubkeyAuthentication yes #启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys #公钥文件路径(和上面生成的文件同)
PermitRootLogin yes #root能使用ssh登录
ClientAliveInterval 60 #参数数值是秒 , 是指超时时间
ClientAliveCountMax 3 #设置允许超时的次数
UsePAM yes 更改为 UsePAM no
Port 80 #指定好端口号,默认是22 后面这个数字要在你run容器的时候用到
按 ESC 输入 :wq 保存

重启ssh服务
service ssh restart

设置ssh密码
passwd root

Tag summary

Content type

Image

Digest

Size

25.9 MB

Last updated

about 4 years ago

docker pull aaron8/ubuntu:20.04