From 913c88e35598b630b434324a7784cc9c5e8e6457 Mon Sep 17 00:00:00 2001 From: Nikola Petkanski Date: Mon, 15 Jul 2024 23:23:53 +0300 Subject: [PATCH] Ability to run privileged containers --- src/Container/Container.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Container/Container.php b/src/Container/Container.php index 1317383..010d7b0 100644 --- a/src/Container/Container.php +++ b/src/Container/Container.php @@ -27,6 +27,7 @@ class Container private Process $process; private WaitInterface $wait; + private bool $privileged = false; private ?string $network = null; private ?string $healthCheckCommand = null; private int $healthCheckIntervalInMS; @@ -108,6 +109,13 @@ public function withPort(string $localPort, string $containerPort): self return $this; } + public function withPrivileged(bool $privileged = true): self + { + $this->privileged = $privileged; + + return $this; + } + public function withNetwork(string $network): self { $this->network = $network; @@ -152,6 +160,10 @@ public function run(bool $wait = true): self $params[] = $this->entryPoint; } + if ($this->privileged) { + $params[] = '--privileged'; + } + $params[] = $this->image; $this->process = new Process($params);