Here are some quick steps to deploy a sshd docker container. It will be based on the official CentOS 7 image from docker hub. It can be used as a light-weight ssh jump server.
First, pull the CentOS 7 image
# docker pull centos:7
Next, create a temp directory. Create a Dockerfile inside with the following content.
FROM centos:7 ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \ systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ rm -f /etc/systemd/system/*.wants/*;\ rm -f /lib/systemd/system/local-fs.target.wants/*; \ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*;\ rm -f /lib/systemd/system/anaconda.target.wants/*; VOLUME [ "/sys/fs/cgroup" ] RUN yum -y install openssh-server openssh-clients RUN echo root:pass | chpasswd RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa RUN ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t ed25519 EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"]
Build the docker image
# docker build -t docker-sshd .
And it’s ready to be ran. Start it up and forward port 22000 to port 22 inside the container
# docker run -p 22000:22 docker-sshd
You can now ssh to the container. Password is set in the Dockerfile.
# ssh -p22000 root@localhost [root@58e6463d5032 ~]# ssh -V OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
Thanks for posting this.