Docker启动容器之后用xshell连接
1. 拉取centos镜像
docker pull centos:tag
2. 启动centos镜像
docker run -tid --name centos8 --privileged=true -p 20022:22 centos:tag /sbin/init
3. 安装备用命令
yum update
yum install -y openssh-clients
yum install -y openssh-server
yum install -y passwd
yum install -y scp
yum install -y bzip2
yum install vixie-cron
yum install crontabs
yum install sudo
sudo yum install vim wget -y
sudo yum install gcc g++ -y
sudo yum install git git-core -y
sudo yum install make cmake -y
4. 设置root密码
passwd root
连续输入两次root就可以了
5. 修改ssh配置
vim /etc/ssh/sshd_config
PermitRootLogin yes
UsePAM no
6. 启动ssh服务
systemctl start sshd