File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
packages/server/src/services Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -372,19 +372,27 @@ export const readPorts = async (
372372 publishedPort : number ;
373373 protocol ?: string ;
374374 } [ ] = [ ] ;
375+ const seenPorts = new Set < string > ( ) ;
375376 for ( const key in parsedResult ) {
376377 if ( Object . hasOwn ( parsedResult , key ) ) {
377378 const containerPortMapppings = parsedResult [ key ] ;
378379 const protocol = key . split ( "/" ) [ 1 ] ;
379380 const targetPort = Number . parseInt ( key . split ( "/" ) [ 0 ] ?? "0" , 10 ) ;
380381
381- containerPortMapppings . forEach ( ( mapping : any ) => {
382- ports . push ( {
383- targetPort : targetPort ,
384- publishedPort : Number . parseInt ( mapping . HostPort , 10 ) ,
385- protocol : protocol ,
386- } ) ;
387- } ) ;
382+ // Take only the first mapping to avoid duplicates (IPv4 and IPv6)
383+ const firstMapping = containerPortMapppings [ 0 ] ;
384+ if ( firstMapping ) {
385+ const publishedPort = Number . parseInt ( firstMapping . HostPort , 10 ) ;
386+ const portKey = `${ targetPort } -${ publishedPort } -${ protocol } ` ;
387+ if ( ! seenPorts . has ( portKey ) ) {
388+ seenPorts . add ( portKey ) ;
389+ ports . push ( {
390+ targetPort : targetPort ,
391+ publishedPort : publishedPort ,
392+ protocol : protocol ,
393+ } ) ;
394+ }
395+ }
388396 }
389397 }
390398 return ports . filter (
You can’t perform that action at this time.
0 commit comments