Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

import com.github.dockerjava.api.model.Version;
import com.github.dockerjava.api.model.VersionComponent;
Expand All @@ -35,6 +36,7 @@ public final class ContainerEnvironmentUtil {
public static final String INFRA_PORT_PROPERTY = "camel.infra.port";
public static final String INFRA_FIXED_PORT_PROPERTY = "camel.infra.fixedPort";
private static final Logger LOG = LoggerFactory.getLogger(ContainerEnvironmentUtil.class);
private static final AtomicInteger INSTANCE_COUNTER = new AtomicInteger(0);

private static boolean dockerAvailable;
private static boolean environmentCheckState;
Expand Down Expand Up @@ -114,6 +116,11 @@ public static String containerName(Class cls) {
if (annotation.serviceImplementationAlias().length > 0) {
name += "-" + annotation.serviceImplementationAlias()[0];
}
// In fixed port mode (camel infra run), use clean names for docker exec usability
// Otherwise, append PID + counter for cross-JVM and within-JVM uniqueness
if (!Boolean.parseBoolean(System.getProperty(INFRA_FIXED_PORT_PROPERTY, "false"))) {
name += "-" + ProcessHandle.current().pid() + "-" + INSTANCE_COUNTER.incrementAndGet();
}
} else {
LOG.warn("InfraService annotation not Found to determine container name alias.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public RocketMQNameserverContainer(Network network) {
addExposedPort(RocketMQProperties.ROCKETMQ_NAMESRV_PORT);
withTmpFs(Collections.singletonMap("/home/rocketmq/logs", "rw"));
withCommand("sh", "mqnamesrv");
withCreateContainerCmdModifier(cmd -> cmd.withName("nameserver"));

waitingFor(Wait.forListeningPort());
}
Expand Down
Loading