예제 #1
0
func executeDockerNs(command *client.SegmentCommand, seg *Segment) error {
	ci := &seg.Head
	if command.Tail {
		ci = &seg.Tail
	}
	var err error
	ci.Ns, err = netns.GetFromDocker(command.Arg)
	return err
}
예제 #2
0
func executeDockerRun(command *client.SegmentCommand, seg *Segment) error {
	ci := &seg.Head
	if command.Tail {
		ci = &seg.Tail
	}
	args := strings.Fields(command.Arg)
	// TODO: use the api here instead of shelling out
	args = append([]string{"run", "-d"}, args...)
	out, err := exec.Command("docker", args...).Output()
	if err != nil {
		return err
	}
	id := strings.TrimSpace(string(out))
	seg.DockerIds = append(seg.DockerIds, id)

	ci.Ns, err = netns.GetFromDocker(id)
	return err
}