func (daemon *Daemon) removeMountPoints(container *container.Container, rm bool) error { var rmErrors []string for _, m := range container.MountPoints { if m.Volume == nil { continue } daemon.volumes.Dereference(m.Volume, container.ID) if rm { // Do not remove named mountpoints // these are mountpoints specified like `docker run -v <name>:/foo` if m.Named { continue } err := daemon.volumes.Remove(m.Volume) // Ignore volume in use errors because having this // volume being referenced by other container is // not an error, but an implementation detail. // This prevents docker from logging "ERROR: Volume in use" // where there is another container using the volume. if err != nil && !volumestore.IsInUse(err) { rmErrors = append(rmErrors, err.Error()) } } } if len(rmErrors) > 0 { return fmt.Errorf("Error removing volumes:\n%v", strings.Join(rmErrors, "\n")) } return nil }
// VolumeRm removes the volume with the given name. // If the volume is referenced by a container it is not removed // This is called directly from the remote API func (daemon *Daemon) VolumeRm(name string) error { v, err := daemon.volumes.Get(name) if err != nil { return err } if err := daemon.volumes.Remove(v); err != nil { if volumestore.IsInUse(err) { return derr.ErrorCodeRmVolumeInUse.WithArgs(err) } return derr.ErrorCodeRmVolume.WithArgs(name, err) } return nil }
// VolumeRm removes the volume with the given name. // If the volume is referenced by a container it is not removed // This is called directly from the remote API func (daemon *Daemon) VolumeRm(name string) error { v, err := daemon.volumes.Get(name) if err != nil { return err } if err := daemon.volumes.Remove(v); err != nil { if volumestore.IsInUse(err) { return derr.ErrorCodeRmVolumeInUse.WithArgs(err) } return derr.ErrorCodeRmVolume.WithArgs(name, err) } daemon.LogVolumeEvent(v.Name(), "destroy", map[string]string{"driver": v.DriverName()}) return nil }
// VolumeRm removes the volume with the given name. // If the volume is referenced by a container it is not removed // This is called directly from the remote API func (daemon *Daemon) VolumeRm(name string) error { v, err := daemon.volumes.Get(name) if err != nil { return err } if err := daemon.volumes.Remove(v); err != nil { if volumestore.IsInUse(err) { err := fmt.Errorf("Unable to remove volume, volume still in use: %v", err) return errors.NewRequestConflictError(err) } return fmt.Errorf("Error while removing volume %s: %v", name, err) } daemon.LogVolumeEvent(v.Name(), "destroy", map[string]string{"driver": v.DriverName()}) return nil }
func (daemon *Daemon) removeMountPoints(container *container.Container, rm bool) error { var rmErrors []string for _, m := range container.MountPoints { if m.Volume == nil { continue } daemon.volumes.Dereference(m.Volume, container.ID) if rm { err := daemon.volumes.Remove(m.Volume) // Ignore volume in use errors because having this // volume being referenced by other container is // not an error, but an implementation detail. // This prevents docker from logging "ERROR: Volume in use" // where there is another container using the volume. if err != nil && !volumestore.IsInUse(err) { rmErrors = append(rmErrors, err.Error()) } } } if len(rmErrors) > 0 { return derr.ErrorCodeRemovingVolume.WithArgs(strings.Join(rmErrors, "\n")) } return nil }