I got a container that has openssh installed and can be connnected via the command ssh 172.17.0.2
.
Now I want to get a port (say 32769) on the host side, and map the port 22 (of docker container) to it, the reason for doing that is I want to get the ssh 127.0.0.1 -p 32769
works on localhost, I got the errors as : ssh_exchange_identification: read: Connection reset by peer
. The port mapping is showing normally on docker engine: 0.0.0.0:32769->22/tcp
.
Can somebody help me with that? Much appreciated!
Check that the SSH daemon is running in your container first (through a docker exec
or docker attach
session):
service ssh status
# or
service sshd status
Make sure you have the right IP address
sudo docker inspect -f "{{ .NetworkSettings.IPAddress }}" Container_Name
Use the right SSH URL:
ssh root@172.17.0.2
See more in " How to SSH into a Running Docker Container and Run Commands " from Sofija Simic.
Using a docker run -p 32769:22
is in your case a good idea.
The OP mentions in the discussion an issue with docker proxy:
The docker-proxy was not getting eth0 of the container as
-container-ip
.
Here is what I've got/usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 32785 \\ -container-ip 172.21.1.2 -container-port 22
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.