// RemoveContainer removes a container simply by name.
181630
func (l *Location) RemoveContainer(id string) error {

	if err := l.client.Buckets.Delete(id).Do(); err != nil {
		return err
	}

	return nil
}
624412
func (m *Mercury) AddContainer(ctx context.Context, container *types.Container) error {
	return m.doOpsContainer(ctx, container, true)
}
1049573
func (l *location) RemoveContainer(id string) error {
	return l.client.ContainerDelete(id)
}
1042434
func (s *Preset) SetContainer(v string) *Preset {
	s.Container = &v
	return s
}
1303965
func (l *location) CreateContainer(name string) (stow.Container, error) {
	err := l.client.ContainerCreate(name, nil)
	if err != nil {
		return nil, err
	}
	container := &container{
		id:     name,
		client: l.client,
	}
	return container, nil
}
771209
func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerRequest) (resp *pb.RemoveContainerResponse, err error) {
	const operation = "remove_container"
	defer func() {
		recordOperation(operation, time.Now())
		recordError(operation, err)
	}()
	logrus.Debugf("RemoveContainerRequest: %+v", req)

	// save container description to print
	c, err := s.GetContainerFromShortID(req.ContainerId)
	if err != nil {
		return nil, err
	}

	_, err = s.ContainerServer.Remove(ctx, req.ContainerId, true)
	if err != nil {
		return nil, err
	}

	logrus.Infof("Removed container %s", c.Description())
	resp = &pb.RemoveContainerResponse{}
	logrus.Debugf("RemoveContainerResponse: %+v", resp)
	return resp, nil
}
42838
func (s *Server) RemoveContainer(name string) error {
	state, eTag, err := s.GetContainerState(name)
	if err != nil {
		return errors.Trace(err)
	}

	if state.StatusCode != api.Stopped {
		req := api.ContainerStatePut{
			Action:   "stop",
			Timeout:  -1,
			Force:    true,
			Stateful: false,
		}
		op, err := s.UpdateContainerState(name, req, eTag)
		if err != nil {
			return errors.Trace(err)
		}
		if err := op.Wait(); err != nil {
			return errors.Trace(err)
		}
	}

	// LXD has issues deleting containers, even if they've been stopped. The
	// general advice passed back from the LXD team is to retry it again, to
	// see if this helps clean up the containers.
	// ZFS exacerbates this more for the LXD setup, but there is no way to
	// know as the LXD client doesn't return typed errors.
	retryArgs := retry.CallArgs{
		Clock: s.Clock(),
		IsFatalError: func(err error) bool {
			return errors.IsBadRequest(err)
		},
		Func: func() error {
			op, err := s.DeleteContainer(name)
			if err != nil {
				// sigh, LXD not found container - it's been deleted so, we
				// just need to return nil.
				if IsLXDNotFound(errors.Cause(err)) {
					return nil
				}
				return errors.BadRequestf(err.Error())
			}
			return errors.Trace(op.Wait())
		},
		Delay:    2 * time.Second,
		Attempts: 3,
	}
	if err := retry.Call(retryArgs); err != nil {
		return errors.Trace(errors.Cause(err))
	}

	return nil
}
606947
func (f *FakeDocker) RemoveImage(name string) error {
	f.RemoveImageName = name
	return f.RemoveImageError
}
70284
func (m *Mercury) RemoveContainer(ctx context.Context, container *types.Container) error {
	if l := len(container.ID); l != 64 {
		return types.NewDetailedErr(types.ErrBadContainerID,
			fmt.Sprintf("containerID: %s, length: %d",
				container.ID, len(container.ID)))
	}
	appname, entrypoint, _, err := utils.ParseContainerName(container.Name)
	if err != nil {
		return err
	}

	return m.CleanContainerData(ctx, container.ID, appname, entrypoint, container.Nodename)
}
782312
func (c *ContainerServer) AddContainer(ctr *oci.Container) {
	sandbox := c.state.sandboxes.Get(ctr.Sandbox())
	if sandbox == nil {
		return
	}
	sandbox.AddContainer(ctr)
	c.state.containers.Add(ctr.ID(), ctr)
}
502912
func (c *Client) RenameContainer(opts RenameContainerOptions) error {
	resp, err := c.do("POST", fmt.Sprintf("/containers/"+opts.ID+"/rename?%s", queryString(opts)), doOptions{
		context: opts.Context,
	})
	if err != nil {
		return err
	}
	resp.Body.Close()
	return nil
}
169397
func (p *Project) NoContainer(c *check.C, service string) {
	validErr := "No container found for '" + service + "' service"
	_, err := p.project.Container(service)
	c.Assert(err, check.NotNil,
		check.Commentf("error while getting the container for service '%s'", service))
	c.Assert(err.Error(), check.Equals, validErr,
		check.Commentf("error while getting the container for service '%s'", service))
}
315452
func (s *DeleteLifecyclePolicyInput) SetContainerName(v string) *DeleteLifecyclePolicyInput {
	s.ContainerName = &v
	return s
}
26870
func (s *LoadBalancer) SetContainerName(v string) *LoadBalancer {
	s.ContainerName = &v
	return s
}
842532
func (r *runtimeVM) StopContainer(ctx context.Context, c *Container, timeout int64) error {
	logrus.Debug("runtimeVM.StopContainer() start")
	defer logrus.Debug("runtimeVM.StopContainer() end")

	// Lock the container
	c.opLock.Lock()
	defer c.opLock.Unlock()

	// Cancel the context before returning to ensure goroutines are stopped.
	ctx, cancel := context.WithCancel(r.ctx)
	defer cancel()

	stopCh := make(chan error)
	go func() {
		if _, _, err := r.wait(ctx, c.ID(), ""); err != nil {
			stopCh <- errdefs.FromGRPC(err)
		}

		close(stopCh)
	}()

	var sig syscall.Signal

	if timeout > 0 {
		sig = c.StopSignal()
		// Send a stopping signal to the container
		if err := r.kill(ctx, c.ID(), "", sig, false); err != nil {
			return err
		}

		timeoutDuration := time.Duration(timeout) * time.Second

		err := r.waitCtrTerminate(sig, stopCh, timeoutDuration)
		if err == nil {
			return nil
		}
		logrus.Warnf("%v", err)
	}

	sig = syscall.SIGKILL
	// Send a SIGKILL signal to the container
	if err := r.kill(ctx, c.ID(), "", sig, false); err != nil {
		return err
	}

	if err := r.waitCtrTerminate(sig, stopCh, killContainerTimeout); err != nil {
		logrus.Errorf("%v", err)
		return err
	}

	return nil
}
978847
func RemoveHelper(name string) {
	helpersMutex.Lock()
	defer helpersMutex.Unlock()

	delete(helpers, name)
}
772625
func (c *Container) Remove(ctx context.Context, removeVolume bool) error {
	return c.client.ContainerRemove(ctx, c.container.ID, types.ContainerRemoveOptions{
		Force:         true,
		RemoveVolumes: removeVolume,
	})
}