Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to run privileged containers #11

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
12 changes: 12 additions & 0 deletions src/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
private Process $process;
private WaitInterface $wait;

private bool $privileged = false;
private ?string $network = null;
private ?string $healthCheckCommand = null;
private int $healthCheckIntervalInMS;
Expand Down Expand Up @@ -108,6 +109,13 @@
return $this;
}

public function withPrivileged(bool $privileged = true): self
{
$this->privileged = $privileged;

return $this;
}

public function withNetwork(string $network): self
{
$this->network = $network;
Expand Down Expand Up @@ -152,6 +160,10 @@
$params[] = $this->entryPoint;
}

if ($this->privileged) {
$params[] = '--privileged';
}

$params[] = $this->image;

$this->process = new Process($params);
Expand Down Expand Up @@ -251,8 +263,8 @@

public function getAddress(): string
{
if ($this->network !== null && !empty($this->inspectedData[0]['NetworkSettings']['Networks'][$this->network]['IPAddress'])) {

Check failure on line 266 in src/Container/Container.php

View workflow job for this annotation

GitHub Actions / build

Offset 'Networks' on array{IPAddress: string} in empty() does not exist.

Check failure on line 266 in src/Container/Container.php

View workflow job for this annotation

GitHub Actions / build

Result of && is always false.
return $this->inspectedData[0]['NetworkSettings']['Networks'][$this->network]['IPAddress'];

Check failure on line 267 in src/Container/Container.php

View workflow job for this annotation

GitHub Actions / build

Offset 'Networks' does not exist on array{IPAddress: string}.
}

return $this->inspectedData[0]['NetworkSettings']['IPAddress'];
Expand Down
Loading