@@ -806,8 +806,6 @@ func (d *DockerRunner) createContainer(ctx context.Context, task *Task) error {
806806 }
807807 mounts = append (mounts , instanceMounts ... )
808808
809- ports := d .dockerParams .DockerPorts ()
810-
811809 // Set the environment variables
812810 envVars := []string {}
813811 if d .dockerParams .DockerPJRTDevice () != "" {
@@ -827,9 +825,19 @@ func (d *DockerRunner) createContainer(ctx context.Context, task *Task) error {
827825 }
828826 }
829827
828+ networkMode := getNetworkMode (task .config .NetworkMode )
829+ ports := d .dockerParams .DockerPorts ()
830+
831+ // Bridge mode - all interfaces
832+ runnerHttpAddress := ""
833+ if networkMode .IsHost () {
834+ runnerHttpAddress = "localhost"
835+ }
836+ shellCommands := d .dockerParams .DockerShellCommands (task .config .ContainerSshKeys , runnerHttpAddress )
837+
830838 containerConfig := & container.Config {
831839 Image : task .config .ImageName ,
832- Cmd : []string {strings .Join (d . dockerParams . DockerShellCommands ( task . config . ContainerSshKeys ) , " && " )},
840+ Cmd : []string {strings .Join (shellCommands , " && " )},
833841 Entrypoint : []string {"/bin/sh" , "-c" },
834842 ExposedPorts : exposePorts (ports ),
835843 Env : envVars ,
@@ -843,7 +851,7 @@ func (d *DockerRunner) createContainer(ctx context.Context, task *Task) error {
843851 }
844852 hostConfig := & container.HostConfig {
845853 Privileged : task .config .Privileged || d .dockerParams .DockerPrivileged (),
846- NetworkMode : getNetworkMode ( task . config . NetworkMode ) ,
854+ NetworkMode : networkMode ,
847855 PortBindings : bindPorts (ports ),
848856 Mounts : mounts ,
849857 ShmSize : task .config .ShmSize ,
@@ -1182,7 +1190,7 @@ func (c *CLIArgs) DockerPJRTDevice() string {
11821190 return c .Docker .PJRTDevice
11831191}
11841192
1185- func (c * CLIArgs ) DockerShellCommands (publicKeys []string ) []string {
1193+ func (c * CLIArgs ) DockerShellCommands (authorizedKeys []string , runnerHttpAddress string ) []string {
11861194 commands := getSSHShellCommands ()
11871195 runnerCommand := []string {
11881196 consts .RunnerBinaryPath ,
@@ -1192,7 +1200,10 @@ func (c *CLIArgs) DockerShellCommands(publicKeys []string) []string {
11921200 "--http-port" , strconv .Itoa (c .Runner .HTTPPort ),
11931201 "--ssh-port" , strconv .Itoa (c .Runner .SSHPort ),
11941202 }
1195- for _ , key := range publicKeys {
1203+ if runnerHttpAddress != "" {
1204+ runnerCommand = append (runnerCommand , "--http-address" , runnerHttpAddress )
1205+ }
1206+ for _ , key := range authorizedKeys {
11961207 runnerCommand = append (runnerCommand , "--ssh-authorized-key" , fmt .Sprintf ("'%s'" , key ))
11971208 }
11981209 return append (commands , strings .Join (runnerCommand , " " ))
0 commit comments