Socker is a Docker SDK implemented in Scala. It provides a fast and secure connection through Unix Domain Sockets in future versions it will also support HTTP connection, inspired by Docker SDK for Python
- Scala version
3.3.0
- Docker engine version
1.43
Still not available on the Maven repository
- Clone the repo:
git clone https://github.com/yacinehechmi/Socker.git
- Build and run via sbt:
sbt
thensbt runMain Main
- Connecting to Docker through a Unix Domain Socket
val docker: Docker = new Docker("/var/run/docker.sock", "localhost")
to interact with the Docker remote API use a Docker class instance
- Using the Docker Class instance
-
Getting the docker version
docker.version()
-
Listing containers (by default it will list all containers including non running ones)
docker.listContainers().get match { case null => println("no containers") case containers => containers.foreach { x => x.Names foreach println } }
-
Listing images
docker.listImages().get match { case null => println("no images") case images => images.foreach {img => img.RepoTags foreach println } }
-
Listing networks
docker.listNetworks().get match { case null => println("no networks") case networks => networks.foreach { net => println(net.Driver) } }
-
Get container by name
val modestGagarin = docker.getContainer("modest_gagarin")
-
Get container by id
val kafkaBroker = docker.getContainer(id = "4e239dke04a")
-
Start a container
kafkaBroker.start()
-
Kill a container
kafkaBroker.kill()
-
Start all containers
docker.listContainers().get foreach(_.start())
- [] Implement HTTP support
- [] Implement secure connection (HTTPS)
- [] Add more endpoints
- [] Work on filters and parameters of each endpoint
- [] Add X-Registry-Auth for authenticating to docker