Implement server deletion

This commit is contained in:
Dane Everitt
2019-12-21 23:23:56 -08:00
parent 038436c781
commit 0866b84d8e
5 changed files with 100 additions and 4 deletions

View File

@@ -325,6 +325,18 @@ func (d *DockerEnvironment) Terminate(signal os.Signal) error {
)
}
// Remove the Docker container from the machine. If the container is currently running
// it will be forcibly stopped by Docker.
func (d *DockerEnvironment) Destroy() error {
ctx := context.Background()
return d.Client.ContainerRemove(ctx, d.Server.Uuid, types.ContainerRemoveOptions{
RemoveVolumes: true,
RemoveLinks: false,
Force: true,
})
}
// Determine the container exit state and return the exit code and wether or not
// the container was killed by the OOM killer.
func (d *DockerEnvironment) ExitState() (uint32, bool, error) {