title: Error while trying to ssh a docker container : System is booting up
body: <p>I am trying to build an image and run container as an ssh server.
  I want to be able to ssh that container (remote_host) from another container (jenkins/jenkins)</p>
  
  <p>I am using a VM with Centos.</p>
  
  <p>I am using this docker file. I run it from my VM host machine(Centos too)</p>
  
  <pre><code>FROM centos
  
  RUN yum -y install openssh-server openssh-clients
  
  RUN useradd -ms /bin/bash remote_user &amp;&amp; \
    echo 'remote_user:12345' | chpasswd &amp;&amp; \
    mkdir /home/remote_user/.ssh &amp;&amp; \
    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 &amp;&amp; \
      chmod 600 /home/remote_user/.ssh/authorized_keys
  
  EXPOSE 22
  RUN /usr/bin/ssh-keygen -A
  CMD ["/usr/sbin/sshd", "-D"]
  </code></pre>
  
  <p>My docker compose file </p>
  
  <pre><code>---
  networks:
    net: ~
  services:
    jenkins:
      container_name: jenkins
      image: jenkins/jenkins
      networks:
        - net
      ports:
        - "8080:8080"
      volumes:
        - "$PWD/jenkins_home:/var/jenkins_home"
    remote_host:
      container_name: remote-host
      image: remote-host
      build:
        context: centos7
      networks:
        - net
  version: "3"
  </code></pre>
  
  <p>I run <code>docker-compose build</code> from my host machine </p>
  
  <pre><code>Building remote_host
  Step 1/8 : FROM centos
   ---&gt; 0f3e07c0138f
  Step 2/8 : RUN yum -y install openssh-server openssh-clients
   ---&gt; Using cache
   ---&gt; 277411f7cc41
  Step 3/8 : RUN useradd -ms /bin/bash remote_user &amp;&amp;   echo 'remote_user:12345' | chpasswd &amp;&amp;   mkdir /home/remote_user/.ssh &amp;&amp;   chmod 700 /home/remote_user/.ssh
   ---&gt; Using cache
   ---&gt; c42b15de9da7
  Step 4/8 : COPY remote-key.pub /home/remote_user/.ssh/authorized_keys
   ---&gt; Using cache
   ---&gt; f205521e83cb
  Step 5/8 : RUN chown remote_user:remote_user -R /home/remote_user/.ssh &amp;&amp;     chmod 600 /home/remote_user/.ssh/authorized_keys
   ---&gt; Using cache
   ---&gt; a7bb438b87ed
  Step 6/8 : EXPOSE 22
   ---&gt; Using cache
   ---&gt; 7f28ef8e4ec9
  Step 7/8 : RUN /usr/bin/ssh-keygen -A
   ---&gt; Using cache
   ---&gt; a4fae9730627
  Step 8/8 : CMD ["/usr/sbin/sshd", "-D"]
   ---&gt; Using cache
   ---&gt; 3fe69c9789a6
  Successfully built 3fe69c9789a6
  Successfully tagged remote-host:latest
  </code></pre>
  
  <p>Then I run <code>docker-compose up -d</code></p>
  
  <p>docker ps give me :    </p>
  
  <pre><code>0f9987444fcf        remote-host         "/usr/sbin/sshd -D"      28 minutes ago      Up 16 minutes       22/tcp                              remote-host
  4c9ba830f419        jenkins/jenkins     "/sbin/tini -- /usr/…"   7 hours ago         Up 7 hours          0.0.0.0:8080-&gt;8080/tcp, 50000/tcp   jenkins 
  </code></pre>
  
  <p>I ssh my first container:</p>
  
  <pre><code>docker exec -it jenkins bash
  </code></pre>
  
  <p>Then When I try to ssh the second container from the first one</p>
  
  <pre><code>ssh remote_user@remote_host
  </code></pre>
  
  <p>I got this error</p>
  
  <pre><code>Are you sure you want to continue connecting (yes/no)?
  remote_user@remote_host's password:12345
  "System is booting up. Unprivileged users are not permitted to log in yet. Please come back later. For technical details, see pam_nologin(8)."
  Authentication failed.
  </code></pre>