https://kotlinlang.org logo
Title
j

Jakob K

04/02/2021, 1:02 PM
Is it possible to make HTTP requests to the Docker Engine API with Ktor? I am asking because that API is using a Unix socket.
n

napperley

04/03/2021, 3:03 AM
Ktor doesn't seem to have support for Unix socket, although Ktor does have raw socket support ( https://ktor.io/docs/servers-raw-sockets.html ) whatever that means.
If you really need Unix socket support then you will have to use Kotlin Native instead of Kotlin JVM. With some of the Kotlin Native targets (linuxX64, linuxArm32Hfp etc) there is built in access to the POSIX API, which will allow you to use Unix sockets. Please refer to the Non Blocking Echo Server for an example: https://github.com/JetBrains/kotlin-native/tree/master/samples/nonBlockingEchoServer
Does Docker allow communication via Pipes? If so then that would be another option since the JVM does have Pipes support (here is an example: http://tutorials.jenkov.com/java-io/pipes.html ).
j

Jakob K

04/03/2021, 1:35 PM
Thank you, I will have look into that pipe option. And if that does not work, maybe I will find an option / workaround to make the Docker Engine API to listen on the HTTP protocol.