Error while trying to ssh a docker container : System is booting up
If the remote_host is not in the process of booting then log into the remote_host, become root and remove /run/nologin file.
Solution:
Please edit your dockerfile like this:
FROM centos
RUN yum -y install openssh-server
RUN useradd remote_user && \
echo remote_user:1234 | chpasswd && \
mkdir /home/remote_user/.ssh && \
chmod 700 /home/remote_user/.ssh
COPY remote-key.pub /home/remote_user/.ssh/authorized_keys
RUN chown remote_user:remote_user -R /home/remote_user/.ssh && \
chmod 600 /home/remote_user/.ssh/authorized_keys
RUN /usr/bin/ssh-keygen -A
EXPOSE 22
RUN rm -rf /run/nologin
CMD /usr/sbin/sshd -D
Solution 1:
Add this command to your code
RUN rm -rf /run/nologin
The above command clears intermediate users(temp users).
Solution 2:
If it doesn't works just REBOOT your VirtualMachine.
I hope my solutions worksfine.