title: SSH to a docker container and execute a Java Program (PSVM)
body: <p>I am new to docker and struggling with my assignment question. It is to execute a Java program after SSH ing to the docker container . </p>
  
  <pre><code>FROM ubuntu:16.04
  
  RUN apt-get update &amp;&amp; apt-get install -y openssh-server
  RUN mkdir /var/run/sshd
  RUN echo 'root:screencast' | chpasswd
  RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' 
  /etc/ssh/sshd_config
  
  # SSH login fix. Otherwise user is kicked off after login
  RUN sed 's@session\s*required\s*pam_loginuid.so@session optional 
  pam_loginuid.so@g' -i /etc/pam.d/sshd
  
  ENV NOTVISIBLE "in users profile"
  RUN echo "export VISIBLE=now" &gt;&gt; /etc/profile
  
  EXPOSE 22
  CMD ["/usr/sbin/sshd", "-D"] 
  
  FROM java:8
  COPY . /var/www/java
  WORKDIR /var/www/java
  </code></pre>
  
  <p>I was able to start the container but when i attempted to ping with the IPAddress i get no response .</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND               CREATED             
  STATUS              PORTS               NAMES
  10301156ddc7        sshsample           "/usr/sbin/sshd -D"   37 
  minutes ago      Up 37 minutes       22/tcp              
  optimistic_bardeen
  </code></pre>
  
  <p>I do have the IP address in my etc/hosts file. </p>
  
  <p>My questions are </p>
  
  <ol>
  <li><p>Why is my ping to the container failing ? </p></li>
  <li><p>I need to SSH into this container and then run a Java Program (PSVM) . </p></li>
  </ol>
  
  <p>After i successfully resolve the pinging issue i am thinking of doing the following </p>
  
  <pre><code>$ssh root@172.17.0.2  
  </code></pre>
  
  <p>Question is </p>
  
  <p>How do i run a java program located in the container after SSH into it ? Executing </p>
  
  <pre><code>&gt;Java HWorld.java will work from the bash shell ?
  </code></pre>
  
  <p>This is my first attempt @ learning docker and so i explained the best i can. Please help.</p>