- SSH Service Installation
- Installing the SSH Service
#yum Install Openssh-server-y
- Install passwd (change password required)
#yum Install Passwd-y
- Modifying the Sshd_config configuration file
Usepam Yes change to Usepam no
- Turn off host SELinux
When you use passwd to modify the root password in the container, you will get an error:
PASSWD:SYSTEM_U:SYSTEM_R:INITRC_T:S0 is isn't authorized to change the password of root
This time, you need to shut down the host SELinux.
- Boot from
Create the run.sh script under the/root directory and add the following: #!/bin/bash service sshd restart while : do sleep 10 done
In fact, from the start can be used in CMD, but temporarily not ... In the way of unified script execution to prevent exit, feel can regulate the line fine.
- Save changes
- To view the container ID that is running
#docker PS
- Commit modified container ID, saved as Centos6.5,tag for sshd
#docker Commit ID Centos6.5:sshd
- Open service
#docker run-d-P 22:22-t centos6.5:sshd/root/run.sh
The container is run in a later mode, and the container's port 22 is mapped to port 22 of the host
In this way, you can connect to the container via SSH from the external network.
Open sshd Service in Docker