Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ object DockerTypesafeConfig extends DockerKitDockerJava {
`ready-checker`: Option[DockerConfigReadyChecker],
`volume-maps`: Seq[VolumeMapping] = Seq.empty,
memory: Option[Long],
`memory-reservation`: Option[Long]) {
`memory-reservation`: Option[Long],
privileged: Boolean = false) {

def toDockerContainer(): DockerContainer = {
val bindPorts = `port-maps`.fold(EmptyPortBindings) { _.values.map(_.asTuple).toMap }.toSeq.map {
Expand All @@ -69,7 +70,8 @@ object DockerTypesafeConfig extends DockerKitDockerJava {

val hostConfig = HostConfig(
memory = memory,
memoryReservation = `memory-reservation`
memoryReservation = `memory-reservation`,
privileged = privileged
)

DockerContainer(
Expand Down
8 changes: 7 additions & 1 deletion core/src/main/scala/com/whisk/docker/DockerContainer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ case class HostConfig(
/**
* the soft limit on memory usage (in bytes)
*/
memoryReservation: Option[Long] = None
memoryReservation: Option[Long] = None,

/**
* whether to run in privileged mode
*/
privileged: Boolean = false

)

case class DockerContainer(image: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class DockerJavaExecutor(override val host: String, client: DockerClient)
.withOption(spec.hostConfig.flatMap(_.memoryReservation)) {
case (config, memoryReservation) => config.withMemoryReservation(memoryReservation)
}
.withOption(spec.hostConfig.map(_.privileged)) {
case (config, privileged) => config.withPrivileged(privileged)
}

val cmd = client
.createContainerCmd(spec.image)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class SpotifyDockerCommandExecutor(override val host: String, client: DockerClie
.withOption(spec.hostConfig.flatMap(_.memoryReservation)) {
case (config, reservation) => config.memoryReservation(reservation)
}
.withOption(spec.hostConfig.map(_.privileged)) {
case (config, privileged) => config.privileged(privileged)
}
.build()
}

Expand Down