add more commands in container manager menu

Signed-off-by: xiechengsheng <XIE1995@whut.edu.cn>
This commit is contained in:
xiechengsheng
2018-06-22 15:41:16 +08:00
parent a3b8585697
commit f7a3d38d6b
6 changed files with 91 additions and 0 deletions

View File

@@ -42,3 +42,24 @@ func (dc *Docker) Remove() error {
}
return nil
}
func (dc *Docker) Pause() error {
if err := dc.client.PauseContainer(dc.id); err != nil {
return fmt.Errorf("cannot pause container: %v", err)
}
return nil
}
func (dc *Docker) Unpause() error {
if err := dc.client.UnpauseContainer(dc.id); err != nil {
return fmt.Errorf("cannot unpause container: %v", err)
}
return nil
}
func (dc *Docker) Restart() error {
if err := dc.client.RestartContainer(dc.id, 3); err != nil {
return fmt.Errorf("cannot restart container: %v", err)
}
return nil
}

View File

@@ -4,4 +4,7 @@ type Manager interface {
Start() error
Stop() error
Remove() error
Pause() error
Unpause() error
Restart() error
}

View File

@@ -17,3 +17,15 @@ func (m *Mock) Stop() error {
func (m *Mock) Remove() error {
return nil
}
func (m *Mock) Pause() error {
return nil
}
func (m *Mock) Unpause() error {
return nil
}
func (m *Mock) Restart() error {
return nil
}

View File

@@ -17,3 +17,15 @@ func (rc *Runc) Stop() error {
func (rc *Runc) Remove() error {
return nil
}
func (rc *Runc) Pause() error {
return nil
}
func (rc *Runc) Unpause() error {
return nil
}
func (rc *Runc) Restart() error {
return nil
}