Пример #1
0
func (svc *IService) Exec(command []string) error {
	ctr, err := docker.FindContainer(svc.name())
	if err != nil {
		return err
	}

	output, err := utils.AttachAndRun(ctr.ID, command)
	if err != nil {
		return err
	}
	os.Stdout.Write(output)
	return nil
}
Пример #2
0
func attachAndRun(dockerID, command string) error {
	if dockerID == "" {
		return errors.New("missing docker ID")
	} else if command == "" {
		return nil
	}

	output, err := utils.AttachAndRun(dockerID, []string{command})
	if err != nil {
		err = fmt.Errorf("%s (%s)", string(output), err)
		glog.Errorf("Could not pause container %s: %s", dockerID, err)
	}
	return err
}
Пример #3
0
// AttachAndRun implements zkdocker.ActionHandler; it attaches to a running
// container and performs a command as specified by the container's service
// definition
func (a *HostAgent) AttachAndRun(dockerID string, command []string) ([]byte, error) {
	return utils.AttachAndRun(dockerID, command)
}