Skip to content

Commit ac65341

Browse files
committed
feat(network): automatically add container name to network alias
1 parent d712f72 commit ac65341

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

testcontainers/src/core/image/image_ext.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,13 @@ impl<RI: Into<ContainerRequest<I>>, I: Image> ImageExt<I> for RI {
236236
}
237237

238238
fn with_container_name(self, name: impl Into<String>) -> ContainerRequest<I> {
239-
let container_req = self.into();
239+
let mut container_req = self.into();
240+
let name = name.into();
240241

241-
ContainerRequest {
242-
container_name: Some(name.into()),
243-
..container_req
244-
}
242+
container_req.network_aliases.insert(name.clone());
243+
container_req.container_name = Some(name);
244+
245+
container_req
245246
}
246247

247248
fn with_network(self, network: impl Into<String>) -> ContainerRequest<I> {

0 commit comments

Comments
 (0)