Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (w *Worker) execcmd(ctx context.Context, cli *client.Client, user string, cmd string) (info types.ContainerExecInspect, err error) {
- ec := types.ExecConfig{}
- ec.Detach = false
- ec.Tty = false
- ec.Cmd = make([]string, 3)
- ec.Cmd[0] = "/bin/bash"
- ec.Cmd[1] = "-c"
- ec.Cmd[2] = cmd
- ec.User = user
- eresp, er := cli.ContainerExecCreate(ctx, w.containerID, ec)
- if er != nil {
- err = errors.Wrap(er, "exec command in container error")
- return
- }
- sc := types.ExecStartCheck{}
- log.Infof("ExecStartCheck %+v", sc)
- sc.Tty = true
- sc.Detach = false
- //log.Infof("exec ID = %s", eresp.ID)
- err = cli.ContainerExecStart(ctx, eresp.ID, sc)
- if err != nil {
- err = errors.Wrap(err, "exec command in container error")
- return
- }
- log.Debugf("Executing exec ID = %s", eresp.ID)
- info, err = cli.ContainerExecInspect(ctx, eresp.ID)
- log.Infof("ONLY FOR CURRENT DEBUG info.ExitCode = %d", info.ExitCode)
- if err != nil {
- err = errors.Wrap(err, "exec command in container error")
- }
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment