@@ -23,48 +23,45 @@ class DockerJavaExecutor(override val host: String, client: DockerClient)
23
23
(volume, new Bind (mapping.host, volume, AccessMode .fromBoolean(mapping.rw)))
24
24
}
25
25
26
- val baseCmd = {
27
- val hostConfig = new com.github.dockerjava.api.model.HostConfig ()
28
- hostConfig
29
- .withOption(spec.networkMode)({ case (config, value) => config.withNetworkMode(value) })
30
- .withPortBindings(spec.bindPorts.foldLeft(new Ports ()) {
31
- case (ps, (guestPort, DockerPortMapping (Some (hostPort), address))) =>
32
- ps.bind(ExposedPort .tcp(guestPort), Ports .Binding .bindPort(hostPort))
33
- ps
34
- case (ps, (guestPort, DockerPortMapping (None , address))) =>
35
- ps.bind(ExposedPort .tcp(guestPort), Ports .Binding .empty())
36
- ps
26
+ val hostConfig = new com.github.dockerjava.api.model.HostConfig ()
27
+ .withOption(spec.networkMode)({ case (config, value) => config.withNetworkMode(value) })
28
+ .withPortBindings(spec.bindPorts.foldLeft(new Ports ()) {
29
+ case (ps, (guestPort, DockerPortMapping (Some (hostPort), address))) =>
30
+ ps.bind(ExposedPort .tcp(guestPort), Ports .Binding .bindPort(hostPort))
31
+ ps
32
+ case (ps, (guestPort, DockerPortMapping (None , address))) =>
33
+ ps.bind(ExposedPort .tcp(guestPort), Ports .Binding .empty())
34
+ ps
35
+ })
36
+ .withLinks(
37
+ new Links (spec.links.map {
38
+ case ContainerLink (container, alias) =>
39
+ new Link (container.name.get, alias)
40
+ }: _* )
41
+ )
42
+ .withBinds(new Binds (volumeToBind.map(_._2): _* ))
43
+
44
+ val cmd = client
45
+ .createContainerCmd(spec.image)
46
+ .withHostConfig(hostConfig)
47
+ .withPortSpecs(spec.bindPorts
48
+ .map({
49
+ case (guestPort, DockerPortMapping (Some (hostPort), address)) =>
50
+ s " $address: $hostPort: $guestPort"
51
+ case (guestPort, DockerPortMapping (None , address)) => s " $address:: $guestPort"
37
52
})
38
- .withLinks(
39
- new Links (spec.links.map {
40
- case ContainerLink (container, alias) =>
41
- new Link (container.name.get, alias)
42
- }: _* )
43
- )
44
- .withBinds(new Binds (volumeToBind.map(_._2): _* ))
45
-
46
- val tmpCmd = client
47
- .createContainerCmd(spec.image)
48
- .withHostConfig(hostConfig)
49
- .withPortSpecs(spec.bindPorts
50
- .map({
51
- case (guestPort, DockerPortMapping (Some (hostPort), address)) =>
52
- s " $address: $hostPort: $guestPort"
53
- case (guestPort, DockerPortMapping (None , address)) => s " $address:: $guestPort"
54
- })
55
- .toSeq: _* )
56
- .withExposedPorts(spec.bindPorts.keys.map(ExposedPort .tcp).toSeq: _* )
57
- .withTty(spec.tty)
58
- .withStdinOpen(spec.stdinOpen)
59
- .withEnv(spec.env: _* )
60
- .withVolumes(volumeToBind.map(_._1): _* )
61
- .withOption(spec.user) { case (config, user) => config.withUser(user) }
62
- .withOption(spec.hostname) { case (config, hostName) => config.withHostName(hostName) }
63
-
64
- spec.name.map(tmpCmd.withName).getOrElse(tmpCmd)
65
- }
53
+ .toSeq: _* )
54
+ .withExposedPorts(spec.bindPorts.keys.map(ExposedPort .tcp).toSeq: _* )
55
+ .withTty(spec.tty)
56
+ .withStdinOpen(spec.stdinOpen)
57
+ .withEnv(spec.env: _* )
58
+ .withVolumes(volumeToBind.map(_._1): _* )
59
+ .withOption(spec.user) { case (config, user) => config.withUser(user) }
60
+ .withOption(spec.hostname) { case (config, hostName) => config.withHostName(hostName) }
61
+ .withOption(spec.name) { case (config, name) => config.withName(name) }
62
+ .withOption(spec.command) { case (config, c) => config.withCmd(c : _* ) }
63
+ .withOption(spec.entrypoint) { case (config, entrypoint) => config.withEntrypoint(entrypoint : _* ) }
66
64
67
- val cmd = spec.command.fold(baseCmd)(c => baseCmd.withCmd(c : _* ))
68
65
Future (cmd.exec()).map { resp =>
69
66
if (resp.getId != null && resp.getId != " " ) {
70
67
resp.getId
0 commit comments