testcontainers-java: Can not set custom container name
Tried to set container name via .setContainerName(), however upon start container still has some random name assigned to it automatically. Did anyone test this? Works from command line with docker run -d --name bla my/image
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (9 by maintainers)
Dont mind. I found a nice workaround:
The documentation of
withCreateContainerCmdModifiersays:To me, this seems like a strong indication for extending the interface of
GenericContainer.IMHO there is always a way to screw things up when configuring containers and hiding existing docker functionality isn’t gonna make testcontainers more valuable. Also it would make sense adding container labelling.
I’m initializing cluster of 3 etcd nodes, where I should link them during start command and this
.withNetworkAliases("foo")works perfectly for me, thanks!@RobMaskell if you use Networks you can (and should) use
withNetworkAliasesto provide a DNS name for your container, see: https://github.com/testcontainers/testcontainers-java/blob/4471878f332dd8e7880fc8a55879a45834556e5e/core/src/test/java/org/testcontainers/containers/NetworkTest.java#L23