docker 2020-06-10

heya, how would i exec a command in container and attach stdin/stdout/stderr/tty?

seems like executing a command and getting streams is bit more complicated than i expected. lol

hey @kahvel_slack unfortunately that would be the way to interact with the container (which is a process) at least from the JVM. Its the same as using the java Process API: https://www.baeldung.com/java-process-api we need to use streams as they provide bidirectional I/O and the ability to build async things on top. This incidentally is the same way a terminal works too when you exec into a container. I hope that addresses some of your doubts?

also did you figure out how to do the exec?

honestly i got :ExecStart working

i used :as :socket

yeah so basically you need to create an exec instance and the call start on it. the exec instance op should return you a stream depending on which of streams you attached to https://docs.docker.com/engine/api/v1.40/#operation/ContainerExec

you can use :as :stream too

stream is not bidirectional though

yeah would need a socket then.