marcuslonnberg / scala-docker   0.7.0

MIT License GitHub

Docker client for Scala

Scala versions: 2.12 2.11 2.10


Scala client using reactive streams (akka-streams) to communicate with Docker hosts.

Build Status


Add as a dependency in your build.sbt:

libraryDependencies += "se.marcuslonnberg" %% "scala-docker" % "0.6.2"


Creating a DockerClient

implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer(ActorMaterializerSettings(system))

val client = new DockerClient(DockerConnection.fromEnvironment())

DockerConnection.fromEnvironment() will know which Docker host to connect to by reading DOCKER_HOST, DOCKER_TLS_VERIFY and DOCKER_CERT_PATH. Host and TLS settings can also be provided as arguments.

Running a container

val imageName = ImageName("fancy-service")
val portBindings: Map[Port, Seq[PortBinding]] = Map(Tcp(8080) -> Seq(PortBinding("", 8080)))

for {
  containerId: ContainerId <-, HostConfig(portBindings = portBindings))
  containerInfo: ContainerInfo <- client.containers.get(containerId)
} yield containerInfo