1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-04 17:33:21 +08:00

Add support for setting stacks when creating session (#138)

* Add support for setting stacks when creating session

* Add exec endpoint and move dns stuff to another package

* Rename command and status code
This commit is contained in:
Marcos Nils
2017-05-11 10:34:16 -03:00
committed by GitHub
parent 24f8c9fc62
commit 62c5d3761d
9 changed files with 187 additions and 86 deletions

View File

@@ -274,3 +274,20 @@ func CreateInstance(session *Session, dindImage string) (*Instance, error) {
func DeleteContainer(id string) error {
return c.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{Force: true, RemoveVolumes: true})
}
func Exec(instanceName string, command []string) (int, error) {
e, err := c.ContainerExecCreate(context.Background(), instanceName, types.ExecConfig{Cmd: command})
if err != nil {
return 0, err
}
err = c.ContainerExecStart(context.Background(), e.ID, types.ExecStartCheck{})
if err != nil {
return 0, err
}
ins, err := c.ContainerExecInspect(context.Background(), e.ID)
if err != nil {
return 0, err
}
return ins.ExitCode, nil
}

View File

@@ -54,6 +54,7 @@ type Session struct {
scheduled bool `json:"-"`
ticker *time.Ticker `json:"-"`
PwdIpAddress string `json:"pwd_ip_address"`
StackFile string `json:"-"`
}
func (s *Session) Lock() {