cd
mkdir devubuntu
cd devubuntu
# vi Dockerfile
FROM ubuntu:latest
RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y inetutils-ping openssh-server && \
rm -rf /var/lib/apt/lists/*
RUN mkdir /run/sshd && \
echo 'root:root' | chpasswd && \
sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config && \
mkdir /root/.ssh
EXPOSE 22/tcp
CMD ["/usr/sbin/sshd","-D"]
docker build -t devubuntu .
docker run --name=devjoy -p 2222:22 -d -t devubuntu3
ssh root@localhost -p 2222
# example, if your docker host ist 192.168.56.101 v
ssh root@192.168.56.101 -p 2222