Connecting inside container at docker environment using JSCH
<p>I am developing a java application to connect (using SSH) a Linux machine attach a docker container and send commands on that.</p>

<p>Now, I am able to connect linux machine, send commands and read the responses, however when I try to attach a container and send commands inside it, nothing is received and I am not able to send commands.</p>

<p>I am usinf code below. Could you please help me with this issue?</p>

<pre><code>try{
  JSch jsch=new JSch();  

  String host=null;
  if(arg.length&gt;0){
    host=arg[0];
  }
  else{
    host=JOptionPane.showInputDialog("Enter username@hostname",
                                     "root@10.46.68.147"); 
  }
  String user=host.substring(0, host.indexOf('@'));
  host=host.substring(host.indexOf('@')+1);

  Session session=jsch.getSession(user, host, 22);
  //Session session=jsch.getSession("root", "10.46.68.147", 4184);

  // username and password will be given via UserInfo interface.
  UserInfo ui=new MyUserInfo();
  session.setUserInfo(ui);
  session.connect();

 String temp = "";
 String all_content = "docker ps -a;docker attach 9071d6cda4d8;client"



 //Open a session and send the commands
  Channel channel=session.openChannel("exec");
  ((ChannelExec) channel).setPty(true); //command for running groove containers
  channel.setXForwarding(true);
  ((ChannelExec)channel).setCommand(all_content);



  channel.setInputStream(null);

  ((ChannelExec)channel).setErrStream(System.err);

  InputStream in=channel.getInputStream();

  channel.connect();
</code></pre>