forked from whisklabs/docker-it-scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Containers
Dmytro Mykhalyk edited this page Nov 28, 2017
·
2 revisions
There are two ways to define a docker container.
Code based definitions and via typesafe-config
.
import com.whisk.docker.{DockerContainer, DockerKit, DockerReadyChecker}
trait DockerMongodbService extends DockerKit {
val DefaultMongodbPort = 27017
val mongodbContainer = DockerContainer("mongo:3.0.6")
.withPorts(DefaultMongodbPort -> None)
.withReadyChecker(DockerReadyChecker.LogLineContains("waiting for connections on port"))
.withCommand("mongod", "--nojournal", "--smallfiles", "--syncdelay", "0")
abstract override def dockerContainers: List[DockerContainer] =
mongodbContainer :: super.dockerContainers
}
You can check usage example
docker-testkit-config
enables you to use a typesafe config to
define your docker containers. Just put an application.conf
file in
your classpath.
The container definitions are nested in the structure of name docker
docker {
...
...
}
See application.conf for more examples.
Usage in code
trait DockerMongodbService extends DockerKitConfig {
val mongodbContainer = configureDockerContainer("docker.mongodb")
abstract override def dockerContainers: List[DockerContainer] =
mongodbContainer :: super.dockerContainers
}
- Cassandra =>
docker.cassandra
- Elasticsearch =>
docker.elasticsearch
- Kafka =>
docker.kafka
- Mongodb =>
docker.mongo
- Neo4j =>
docker.neo4j
- Postgres =>
docker.postgres
-
image-name
required (String) -
environmental-variables
optional (Array of Strings) -
ready-checker
optional structure-
log-line
optional (String) -
http-response-code
-
code
optional (Int - defaults to200
) -
port
required (Int) -
path
optional (String - defaults to/
) -
within
optional (Int) -
looped
optional structure-
attempts
required (Int) -
delay
required (Int)
-
-
-
-
port-maps
optional structure (list of structures)-
SOME_MAPPING_NAME
-
internal
required (Int) -
external
optional (Int)
-
-
-
volume-maps
optional structure (list of structures)-
container
required (String) -
host
required (String) -
rw
optional (Boolean - default:false)
-