Skip to content
Dmytro Mykhalyk edited this page Nov 28, 2017 · 2 revisions

Setup envirounment

docker-it-scala can work with two underlying libraries to communicate to docker engine through REST API or unix socket.

Note: there is no specific recommendation to use one of them, over the other, but we hear people using Spotify's one more often, so you might get better support for it.

There are separate artifacts available for these libraries:

Spotify's docker-client

libraryDependencies ++= Seq(
  "com.whisk" %% "docker-testkit-scalatest" % "0.9.5" % "test",
  "com.whisk" %% "docker-testkit-impl-spotify" % "0.9.5" % "test")

docker-java

libraryDependencies ++= Seq(
  "com.whisk" %% "docker-testkit-scalatest" % "0.9.5" % "test",
  "com.whisk" %% "docker-testkit-impl-docker-java" % "0.9.5" % "test")

You don't necessarily have to use scalatest dependency as demonstrated above. You can create your custom bindings into your test environment, whether you use different initialisation technique or different framework. Have a look at this specific trait

Overriding execution environment

If you need to have custom setup for you environment, you need to override dockerFactory field, providing DockerClient instance

import com.spotify.docker.client.{DefaultDockerClient, DockerClient}
import com.whisk.docker.{DockerFactory, DockerKit}

trait MyCustomDockerKitSpotify extends DockerKit {

  private val client: DockerClient = DefaultDockerClient.fromEnv().build()

  override implicit val dockerFactory: DockerFactory = new SpotifyDockerFactory(client)
}

Check docker-client library project for configuration options.

Configuration

You should be able to provide configuration purely through environment variables.

Examples:

export DOCKER_HOST=tcp://127.0.0.1:2375
export DOCKER_HOST=unix:///var/run/docker.sock
Clone this wiki locally