Fork me on GitHub
#docker
<
2020-06-10
>
mikroskeem13:06:07

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

mikroskeem13:06:32

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

lispyclouds17:06:01

hey @U011YV400HX 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?

lispyclouds17:06:34

also did you figure out how to do the exec?

mikroskeem17:06:17

honestly i got :ExecStart working

mikroskeem17:06:22

i used :as :socket

lispyclouds17:06:44

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

lispyclouds17:06:58

you can use :as :stream too

mikroskeem17:06:45

stream is not bidirectional though

lispyclouds17:06:36

yeah would need a socket then.