-
Notifications
You must be signed in to change notification settings - Fork 549
Support for attaching to std in is missing. #156
Comments
Just to clarify are you referring to the fact that one is not able to send data back through the stream sent back by attachContainer ? I don't believe there's a clean way of doing this (although it is possible). As far as I can tell, the problem is docker-client can't provide this due to Apache HttpClient's lack of support for hijacking |
similar case here, i'd like to send data via stdin when execStart so as long as the docker client use apache httpComponents which does not support hijacking, does it mean docker-client won't support this feature neither? thanks |
In case anyone would be interested in just getting something "working", one can always use reflection to traverse the various fields, to the level below apache-httpclient and then cast that object to an interface that permits write operations. I was able to do this for Linux Tools Docker Plugin to support interacting with a container started as a shell. It's far from ideal, but even dockerpy traverses internal fields to do the same. |
The workaround of the previous comment does not work with the latest version. Therefore, here is my fixed implementation, for those who search one. Note, that I removed much of the code, that I personally do not need for my project (like the eclipse-platform dependencies) - so if you need them, re-include them by merging the two work-arounds. |
@Cydhra Hi I am new to the docker , I am facing similar Issue but in a different way. I am trying to run a java program on docker using execStart(execCreation) method of docker client. I tried to use your Hijacking class but i couldn't figure out how could i send the stdin. Below is my code for your reference .It could be of great help if you advise something. package com.examenginedashboard.docker.utils; import java.util.ArrayList; import com.spotify.docker.client.DefaultDockerClient; public class CodeCompiler {
/* ---------------------------------------------------after this I need to pass the stdin-------------------------------*/
}
} I have mentioned my comments the program where exactly i need to pass the input. I am using the below command to run the java program. |
The Workaround provides you with a method, that takes a LogStream object (like your "output" variable). It then returns a WriteableByteChannel, that can either be transformed into an OutputStream or you can write directly into it (see the Java Channel API). If you choose to get an OutputStream of it, you can then write anything into this OutputStream which will be forwarded into the standard input of the Docker-Container. So if anything inside the container waits for user input, it will receive, what you write into the OutputStream. For further reference, see SmartLambda, where I used this workaround. The package docker contains the code, that communicates with the application inside the container. |
@Cydhra Thank you for replyin, you really raised my hope. I have done the changes as per your comment. I was getting some casting error in the hijacking file i was able to resolve those though. Though my code does not throw any error, i am not sure whether it is writing to the writable channel or not. Below is both of my code . If you could tell what I am doing wrong it would be of great help!!. Please find my code below. package com.examenginedashboard.docker.utils; import java.io.ByteArrayInputStream; import com.spotify.docker.client.DefaultDockerClient;
} package com.examenginedashboard.docker.utils;
import java.io.FilterInputStream; import org.apache.http.conn.EofSensorInputStream; import sun.nio.ch.ChannelInputStream; import com.spotify.docker.client.LogReader;
|
@Cydhra Here I am again, May be i didn't appreciate, I apologize for that. Actually your code helped alot and very close to what I am trying to achieve and your help can lead me upto there.If you could suggest me it would be very helpful. Following is the way i am wriiting into the channel.
So basically I am wrinting string "rock" into the channel which is an input to the program. Once the input is passed the program will execute and I am sure it must be getting executed. But there is no way i could find how to get the final executed program output. Please suggest something it will be of great help. Thank you very much for everything you provided so far. Thanks in advance. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi all, Since this project went on mature status, please re-open this issue (if it still stands) to https://github.com/dmandalidis/docker-client. Thanks |
No description provided.
The text was updated successfully, but these errors were encountered: