Skip to content
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
19 changes: 18 additions & 1 deletion src/Container/GenericContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class GenericContainer implements TestContainer

protected ?string $networkName = null;

/** @var array<string> */
protected array $aliases = [];

protected ?string $user = null;

protected ?string $workingDir = null;
Expand Down Expand Up @@ -263,6 +266,16 @@ public function withNetwork(string $networkName): static
return $this;
}

/**
* @param array<string> $aliases
*/
public function withAliases(array $aliases): static
{
$this->aliases = $aliases;

return $this;
}

public function withPortGenerator(PortGenerator $portGenerator): static
{
$this->portGenerator = $portGenerator;
Expand Down Expand Up @@ -412,10 +425,14 @@ protected function createContainerConfig(): ContainersCreatePostBody

if ($this->networkName !== null) {
$networkingConfig = new NetworkingConfig();
$aliases = $this->aliases ?? [];
if ($this->name) {
$aliases[] = $this->name;
}
$endpointsConfig = [
$this->networkName => new EndpointSettings([
'networkID' => $this->networkName,
'aliases' => $this->name ? [$this->name] : [],
'aliases' => $aliases,
]),
];
$networkingConfig->setEndpointsConfig($endpointsConfig);
Expand Down