Remove volume when deleting container
This commit is contained in:
@@ -45,7 +45,7 @@ type DockerApi interface {
|
|||||||
ContainerRename(old, new string) error
|
ContainerRename(old, new string) error
|
||||||
CreateAttachConnection(name string) (net.Conn, error)
|
CreateAttachConnection(name string) (net.Conn, error)
|
||||||
CopyToContainer(containerName, destination, fileName string, content io.Reader) error
|
CopyToContainer(containerName, destination, fileName string, content io.Reader) error
|
||||||
DeleteContainer(id string) error
|
DeleteContainer(name string) error
|
||||||
CreateContainer(opts CreateContainerOpts) error
|
CreateContainer(opts CreateContainerOpts) error
|
||||||
GetContainerIPs(id string) (map[string]string, error)
|
GetContainerIPs(id string) (map[string]string, error)
|
||||||
ExecAttach(instanceName string, command []string, out io.Writer) (int, error)
|
ExecAttach(instanceName string, command []string, out io.Writer) (int, error)
|
||||||
@@ -223,8 +223,9 @@ func (d *docker) CopyToContainer(containerName, destination, fileName string, co
|
|||||||
return d.c.CopyToContainer(context.Background(), containerName, destination, r, types.CopyToContainerOptions{AllowOverwriteDirWithFile: true})
|
return d.c.CopyToContainer(context.Background(), containerName, destination, r, types.CopyToContainerOptions{AllowOverwriteDirWithFile: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *docker) DeleteContainer(id string) error {
|
func (d *docker) DeleteContainer(name string) error {
|
||||||
return d.c.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{Force: true, RemoveVolumes: true})
|
d.c.VolumeRemove(context.Background(), name, true)
|
||||||
|
return d.c.ContainerRemove(context.Background(), name, types.ContainerRemoveOptions{Force: true, RemoveVolumes: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateContainerOpts struct {
|
type CreateContainerOpts struct {
|
||||||
@@ -322,7 +323,7 @@ func (d *docker) CreateContainer(opts CreateContainerOpts) (err error) {
|
|||||||
DriverOpts: map[string]string{
|
DriverOpts: map[string]string{
|
||||||
"size": config.DindVolumeSize,
|
"size": config.DindVolumeSize,
|
||||||
},
|
},
|
||||||
Name: opts.SessionId,
|
Name: opts.ContainerName,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user