First make sure that docker has been installed on this machine, if docker is not installed, please click Linux to install docker
Pull the CentOS7 image
Pull the latest version of the mirror
docker pull centos
Pull the specified version mirror
docker pull centos:7.9.2009
Here I take Centos7 as an example:
create container
The ssh port 22 of CentOs is mapped to 10022 of the host
docker run -tid --name centos-radius --privileged=true -p 10022:22 centos:7.9.2009 /usr/sbin/init
The container is successfully created and you can see the container:
Centos container installation software
into the container
docker exec -it centos-radius bash
Install reset password software
yum install -y passwd
reset Password
passwd root
install ifconfig
can get ip
yum install -y net-tools
Install sshServer
yum install -y openssh-server
start ssh service
systemctl start sshd.service
Xshell connects to Docker version of CentOS
Use the host ip, port number 10022 that we mapped container 22, user name root, and password that we reset in the container.
Note that if the host is a cloud server, etc., port number 10022 needs to be opened.