@@ -159,10 +159,17 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
159159 LOG .info ("Starting session for " + sessionRequest .getDesiredCapabilities ());
160160
161161 int port = runningInDocker ? 4444 : PortProber .findFreePort ();
162- // Using timestamp + short UUID to avoid conflicts in concurrent session creation
162+ // Generate unique identifier for consistent naming between browser and recorder containers
163+ // Using browserName-timestamp-UUID to avoid conflicts in concurrent session creation
164+ String browserName = sessionRequest .getDesiredCapabilities ().getBrowserName ();
165+ if (browserName != null && !browserName .isEmpty ()) {
166+ browserName = browserName .toLowerCase ();
167+ } else {
168+ browserName = "unknown" ;
169+ }
163170 long timestamp = System .currentTimeMillis ();
164- String uniqueId = UUID .randomUUID ().toString ().substring (0 , 6 );
165- String sessionIdentifier = timestamp + "-" + uniqueId ;
171+ String uniqueId = UUID .randomUUID ().toString ().substring (0 , 8 );
172+ String sessionIdentifier = String . format ( "%s-%d-%s" , browserName , timestamp , uniqueId ) ;
166173 try (Span span = tracer .getCurrentContext ().createSpan ("docker_session_factory.apply" )) {
167174 AttributeMap attributeMap = tracer .createAttributeMap ();
168175 attributeMap .put (AttributeKey .LOGGER_CLASS .getKey (), this .getClass ().getName ());
@@ -312,8 +319,7 @@ private Container createBrowserContainer(
312319 long browserContainerShmMemorySize = 2147483648L ; // 2GB
313320
314321 // Generate container name: browser-<browserName>-<timestamp>-<uuid>
315- String browserName = stereotype .getBrowserName ().toLowerCase ();
316- String containerName = String .format ("browser-%s-%s" , browserName , sessionIdentifier );
322+ String containerName = String .format ("browser-%s" , sessionIdentifier );
317323
318324 ContainerConfig containerConfig =
319325 image (browserImage )
@@ -380,8 +386,7 @@ private Container startVideoContainer(
380386 Map <String , String > volumeBinds = Collections .singletonMap (hostPath , "/videos" );
381387
382388 // Generate container name: recorder-<browserName>-<timestamp>-<uuid>
383- String browserName = stereotype .getBrowserName ().toLowerCase ();
384- String containerName = String .format ("recorder-%s-%s" , browserName , sessionIdentifier );
389+ String containerName = String .format ("recorder-%s" , sessionIdentifier );
385390
386391 ContainerConfig containerConfig =
387392 image (videoImage )
0 commit comments