Fix port bindings
This commit is contained in:
parent
4a22822c10
commit
a52e09ffef
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -306,22 +305,22 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
portmaps := nat.PortMap{}
|
portBindings := nat.PortMap{
|
||||||
|
"8000/tcp": []nat.PortBinding{
|
||||||
portbindingsHTTP := make([]nat.PortBinding, 1)
|
{
|
||||||
portbindingsHTTP[0] = nat.PortBinding{
|
HostIP: "0.0.0.0",
|
||||||
HostIP: "0.0.0.0",
|
HostPort: strconv.Itoa(HTTPPort),
|
||||||
HostPort: strconv.Itoa(HTTPPort),
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
portmaps["8000"] = portbindingsHTTP
|
|
||||||
|
|
||||||
if SSHPort != 0 {
|
if SSHPort != 0 {
|
||||||
portbindingsSSH := make([]nat.PortBinding, 1)
|
portBindings["22/tcp"] = []nat.PortBinding{
|
||||||
portbindingsSSH[0] = nat.PortBinding{
|
{
|
||||||
HostIP: "0.0.0.0",
|
HostIP: "0.0.0.0",
|
||||||
HostPort: strconv.Itoa(SSHPort),
|
HostPort: strconv.Itoa(SSHPort),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
portmaps["22"] = portbindingsSSH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createdContainer, err := cli.ContainerCreate(
|
createdContainer, err := cli.ContainerCreate(
|
||||||
@ -331,6 +330,10 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i
|
|||||||
Env: []string{},
|
Env: []string{},
|
||||||
Image: image,
|
Image: image,
|
||||||
Cmd: cmd,
|
Cmd: cmd,
|
||||||
|
ExposedPorts: nat.PortSet{
|
||||||
|
nat.Port("22/tcp"): struct{}{},
|
||||||
|
nat.Port("8000/tcp"): struct{}{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
&container.HostConfig{
|
&container.HostConfig{
|
||||||
Resources: container.Resources{
|
Resources: container.Resources{
|
||||||
@ -339,7 +342,7 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i
|
|||||||
Memory: int64(memory*110/100) * 1024 * 1024, // Allow 10 % more memory so we have space for MemoryReservation
|
Memory: int64(memory*110/100) * 1024 * 1024, // Allow 10 % more memory so we have space for MemoryReservation
|
||||||
MemoryReservation: int64(memory) * 1024 * 1024, // This should provide softer way how to limit the memory of our containers
|
MemoryReservation: int64(memory) * 1024 * 1024, // This should provide softer way how to limit the memory of our containers
|
||||||
},
|
},
|
||||||
PortBindings: portmaps,
|
PortBindings: portBindings,
|
||||||
AutoRemove: false,
|
AutoRemove: false,
|
||||||
RestartPolicy: container.RestartPolicy{
|
RestartPolicy: container.RestartPolicy{
|
||||||
Name: "on-failure",
|
Name: "on-failure",
|
||||||
@ -427,7 +430,6 @@ func (d *Driver) Exec(name string, cmd []string, stdin string, env []string, att
|
|||||||
stdouterr := []byte{}
|
stdouterr := []byte{}
|
||||||
if attachStdout {
|
if attachStdout {
|
||||||
stdouterr, err = ioutil.ReadAll(respAttach.Reader)
|
stdouterr, err = ioutil.ReadAll(respAttach.Reader)
|
||||||
fmt.Println(string(stdouterr))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &stdouterr, err
|
return &stdouterr, err
|
||||||
|
@ -14,8 +14,8 @@ const passwordFile = "/srv/.rosti"
|
|||||||
|
|
||||||
// Process contains info about background application usually running in supervisor
|
// Process contains info about background application usually running in supervisor
|
||||||
type Process struct {
|
type Process struct {
|
||||||
Name string
|
Name string `json:"name"`
|
||||||
State string
|
State string `json:"state"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container extends App struct from App
|
// Container extends App struct from App
|
||||||
|
Loading…
Reference in New Issue
Block a user