Skip to content

Commit 5da1e22

Browse files
authored
Merge pull request #60 from nightio/auto-remove-container
Add support for container auto-remove option
2 parents ecdef9b + 08bb2ad commit 5da1e22

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Container/GenericContainer.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class GenericContainer implements TestContainer
4747
/** @var list<string> */
4848
protected array $command = [];
4949

50+
protected bool $autoRemove = false;
51+
5052
protected ?string $entryPoint = null;
5153

5254
protected ?HealthConfig $healthConfig = null;
@@ -120,6 +122,13 @@ public function withCommand(array $command): static
120122
return $this;
121123
}
122124

125+
public function withAutoRemove(bool $autoRemove): static
126+
{
127+
$this->autoRemove = $autoRemove;
128+
129+
return $this;
130+
}
131+
123132
/**
124133
* @param array<array{source: string, target: string, mode?: int}> $files
125134
*/
@@ -455,6 +464,8 @@ protected function createHostConfig(): ?HostConfig
455464

456465
$hostConfig = new HostConfig();
457466

467+
$hostConfig->setAutoRemove($this->autoRemove);
468+
458469
if ($this->exposedPorts !== []) {
459470
$portBindings = $this->createPortBindings();
460471
$hostConfig->setPortBindings($portBindings);

0 commit comments

Comments
 (0)