@@ -104,10 +104,10 @@ export class SetupDockerContainer extends AsyncTask {
104104
105105 // example: 8080:8080/tcp
106106 if ( publicAndPrivatePort . length == 2 ) {
107- publicPortArray [ `${ publicAndPrivatePort [ 1 ] } /${ protocol } ` ] = [
108- { HostPort : publicAndPrivatePort [ 0 ] }
109- ] ;
110- exposedPorts [ ` ${ publicAndPrivatePort [ 1 ] } / ${ protocol } ` ] = { } ;
107+ const portKey = `${ publicAndPrivatePort [ 1 ] } /${ protocol } ` ;
108+ publicPortArray [ portKey ] ||= [ ] ;
109+ publicPortArray [ portKey ] . push ( { HostPort : publicAndPrivatePort [ 0 ] } ) ;
110+ exposedPorts [ portKey ] = { } ;
111111 logOpenedPorts . push ( {
112112 host : publicAndPrivatePort [ 0 ] ,
113113 container : Number ( publicAndPrivatePort [ 1 ] ) ,
@@ -118,10 +118,13 @@ export class SetupDockerContainer extends AsyncTask {
118118
119119 // example: 127.0.0.1:8080:8080/tcp
120120 if ( publicAndPrivatePort . length == 3 ) {
121- publicPortArray [ `${ publicAndPrivatePort [ 2 ] } /${ protocol } ` ] = [
122- { HostIp : publicAndPrivatePort [ 0 ] , HostPort : publicAndPrivatePort [ 1 ] }
123- ] ;
124- exposedPorts [ `${ publicAndPrivatePort [ 2 ] } /${ protocol } ` ] = { } ;
121+ const portKey = `${ publicAndPrivatePort [ 2 ] } /${ protocol } ` ;
122+ publicPortArray [ portKey ] ||= [ ] ;
123+ publicPortArray [ portKey ] . push ( {
124+ HostIp : publicAndPrivatePort [ 0 ] ,
125+ HostPort : publicAndPrivatePort [ 1 ]
126+ } ) ;
127+ exposedPorts [ portKey ] = { } ;
125128 logOpenedPorts . push ( {
126129 host : publicAndPrivatePort [ 0 ] + ":" + publicAndPrivatePort [ 1 ] ,
127130 container : Number ( publicAndPrivatePort [ 2 ] ) ,
@@ -144,6 +147,22 @@ export class SetupDockerContainer extends AsyncTask {
144147 extraBinds . push ( { hostPath, containerPath } ) ;
145148 }
146149
150+ const parseBlkioString = ( input : string ) => {
151+ const match = input . trim ( ) . match ( / ^ ( [ ^ : ] + ) : ( \d + ) ( [ K M G ] ? B ? ) $ / i) ;
152+ if ( ! match ) return null ;
153+ const unit = ( match [ 3 ] || "" ) . charAt ( 0 ) . toUpperCase ( ) ;
154+ const multipliers : Record < string , number > = { K : 1024 , M : 1024 ** 2 , G : 1024 ** 3 } ;
155+ return { Path : match [ 1 ] . trim ( ) , Rate : parseInt ( match [ 2 ] ) * ( multipliers [ unit ] || 1 ) } ;
156+ } ;
157+
158+ const deviceReadBps = ( dockerConfig . deviceReadBps || [ ] )
159+ . map ( parseBlkioString )
160+ . filter ( ( v ) => v !== null ) ;
161+
162+ const deviceWriteBps = ( dockerConfig . deviceWriteBps || [ ] )
163+ . map ( parseBlkioString )
164+ . filter ( ( v ) => v !== null ) ;
165+
147166 // memory limit
148167 let maxMemory : number | undefined = undefined ;
149168 if ( typeof dockerConfig . memory === "number" && dockerConfig . memory > 0 )
@@ -403,6 +422,8 @@ export class SetupDockerContainer extends AsyncTask {
403422 "mcsmanager.instance.uuid" : instance . instanceUuid
404423 } ,
405424 HostConfig : {
425+ BlkioDeviceReadBps : deviceReadBps . length > 0 ? deviceReadBps : undefined ,
426+ BlkioDeviceWriteBps : deviceWriteBps . length > 0 ? deviceWriteBps : undefined ,
406427 Memory : maxMemory ,
407428 MemorySwap : memorySwap ,
408429 MemorySwappiness : memorySwappiness ,
0 commit comments