下载镜像
预装了ubuntu18.04, mysql无密码, ifconfig, brctl, ping命令
~ $ docker pull tyronezhao/network-ubuntu18.04:latest
latest: Pulling from tyronezhao/network-ubuntu18.04
898c46f3b1a1: Already exists
63366dfa0a50: Already exists
041d4cd74a92: Already exists
6e1bee0f8701: Already exists
23ff9e230cab: Pull complete
68fdf77066e7: Pull complete
aae5ec6170eb: Pull complete
2477156481e4: Pull complete
Digest: sha256:d86f70d50aadf903a9ccc43b6ab6cacb385a83603eca04ee3234fe500a42b053
Status: Downloaded newer image for tyronezhao/network-ubuntu18.04:latest
启动容器
~ $ docker run -idt -p 10001:1234 tyronezhao/network-ubuntu18.04:latest /bin/bash
56ffc76ed0a1c28198f514c1cacfd0241e0cf1b5d7b574ec78036ba45cc9e0a8
~ $ docker attach 容器id,这里是56f
开启ssh服务
root@56ffc76ed0a1:/# service ssh start
* Starting OpenBSD Secure Shell server sshd [ OK ]
root@56ffc76ed0a1:/# service ssh status
* sshd is running
root@56ffc76ed0a1:/#
登录容器
~ $ ssh root@localhost -p 10001
root@localhost's password: 默认123456, 修改使用命令passwd root
Last login: Mon Mar 25 10:45:11 2019 from 172.17.0.1
root@56ffc76ed0a1:~#