File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ class GenericContainer implements TestContainer
6464
6565 protected ?string $ networkName = null ;
6666
67+ /** @var array<string> */
68+ protected array $ aliases = [];
69+
6770 protected ?string $ user = null ;
6871
6972 protected ?string $ workingDir = null ;
@@ -263,6 +266,16 @@ public function withNetwork(string $networkName): static
263266 return $ this ;
264267 }
265268
269+ /**
270+ * @param array<string> $aliases
271+ */
272+ public function withAliases (array $ aliases ): static
273+ {
274+ $ this ->aliases = $ aliases ;
275+
276+ return $ this ;
277+ }
278+
266279 public function withPortGenerator (PortGenerator $ portGenerator ): static
267280 {
268281 $ this ->portGenerator = $ portGenerator ;
@@ -412,10 +425,14 @@ protected function createContainerConfig(): ContainersCreatePostBody
412425
413426 if ($ this ->networkName !== null ) {
414427 $ networkingConfig = new NetworkingConfig ();
428+ $ aliases = $ this ->aliases ?? [];
429+ if ($ this ->name ) {
430+ $ aliases [] = $ this ->name ;
431+ }
415432 $ endpointsConfig = [
416433 $ this ->networkName => new EndpointSettings ([
417434 'networkID ' => $ this ->networkName ,
418- 'aliases ' => $ this -> name ? [ $ this -> name ] : [] ,
435+ 'aliases ' => $ aliases ,
419436 ]),
420437 ];
421438 $ networkingConfig ->setEndpointsConfig ($ endpointsConfig );
You can’t perform that action at this time.
0 commit comments