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:
@@ -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
|
||||
|
||||
}
|
||||
|
@@ -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() {
|
||||
|
Reference in New Issue
Block a user