Reputation: 11
guys. I wanna set an ssh connection for my docker. Here are my steps.
My information:
Ubuntu:
pull docker
docker pull citybrainchallenge/cbengine:0.1.1
go into the container, steps 2-5 are executed in the docker
docker run -it citybrainchallenge/cbengine:0.1.1 bash
install dependencies
apt-get update
apt-get install passwd openssl openssh-server openssh-clients
change password
passwd
set the configuration, remove #
vim /etc/ssh/sshd_config
PubkeyAuthentication yes
PermitRootLogin yes
Port 22
save the container
docker ps # check the container id
docker commit container_id new_image_id(I set: citybrainchallenge/cbengine:2.2)
run the new container and test it
docker run -it citybrainchallenge/cbengine:2.2 bash
In the container, restart ssh
service restart ssh
service --status-all # check ssh is +
open a new terminal, Test its connection
docker ps
docker port container_id 22
However, it didn't work.
Upvotes: 1
Views: 385
Reputation: 149
When you are running the container can you pass port forwarding argument and check if that is working docker run -p 22:22
Upvotes: 1