docker

mikroskeem 2020-06-10T13:00:07.077100Z

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

mikroskeem 2020-06-10T13:00:32.077200Z

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

lispyclouds 2020-06-10T17:19:01.077400Z

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?

lispyclouds 2020-06-10T17:19:34.077800Z

also did you figure out how to do the exec?

mikroskeem 2020-06-10T17:24:17.078300Z

honestly i got :ExecStart working

mikroskeem 2020-06-10T17:24:22.078600Z

i used :as :socket

lispyclouds 2020-06-10T17:27:44.079100Z

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

lispyclouds 2020-06-10T17:27:58.079400Z

you can use :as :stream too

lispyclouds 2020-06-10T17:34:44.080400Z

this conversation may help https://clojurians-log.clojureverse.org/docker/2020-05-29

mikroskeem 2020-06-10T17:50:45.081100Z

stream is not bidirectional though

lispyclouds 2020-06-10T17:54:36.081300Z

yeah would need a socket then.