mirror of https://github.com/docker/docs.git
docker run -c COMMENT
This commit is contained in:
parent
bcfe2aa2a7
commit
4f3362b85a
|
@ -333,9 +333,10 @@ func (srv *Server) CmdPs(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
}
|
}
|
||||||
w := tabwriter.NewWriter(stdout, 12, 1, 3, ' ', 0)
|
w := tabwriter.NewWriter(stdout, 12, 1, 3, ' ', 0)
|
||||||
if (!*quiet) {
|
if (!*quiet) {
|
||||||
fmt.Fprintf(w, "ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\n")
|
fmt.Fprintf(w, "ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tCOMMENT\n")
|
||||||
}
|
}
|
||||||
for _, container := range srv.containers.List() {
|
for _, container := range srv.containers.List() {
|
||||||
|
comment := container.GetUserData("comment")
|
||||||
if !container.State.Running && !*fl_all {
|
if !container.State.Running && !*fl_all {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -350,6 +351,7 @@ func (srv *Server) CmdPs(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
/* COMMAND */ command,
|
/* COMMAND */ command,
|
||||||
/* CREATED */ future.HumanDuration(time.Now().Sub(container.Created)) + " ago",
|
/* CREATED */ future.HumanDuration(time.Now().Sub(container.Created)) + " ago",
|
||||||
/* STATUS */ container.State.String(),
|
/* STATUS */ container.State.String(),
|
||||||
|
/* COMMENT */ comment,
|
||||||
} {
|
} {
|
||||||
if idx == 0 {
|
if idx == 0 {
|
||||||
w.Write([]byte(field))
|
w.Write([]byte(field))
|
||||||
|
@ -522,7 +524,7 @@ func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (srv *Server) CreateContainer(img *image.Image, tty bool, openStdin bool, cmd string, args ...string) (*docker.Container, error) {
|
func (srv *Server) CreateContainer(img *image.Image, tty bool, openStdin bool, comment string, cmd string, args ...string) (*docker.Container, error) {
|
||||||
id := future.RandomId()
|
id := future.RandomId()
|
||||||
container, err := srv.containers.Create(id, cmd, args, img.Layers,
|
container, err := srv.containers.Create(id, cmd, args, img.Layers,
|
||||||
&docker.Config{Hostname: id, Tty: tty, OpenStdin: openStdin})
|
&docker.Config{Hostname: id, Tty: tty, OpenStdin: openStdin})
|
||||||
|
@ -533,6 +535,10 @@ func (srv *Server) CreateContainer(img *image.Image, tty bool, openStdin bool, c
|
||||||
srv.containers.Destroy(container)
|
srv.containers.Destroy(container)
|
||||||
return nil, errors.New("Error setting container userdata: " + err.Error())
|
return nil, errors.New("Error setting container userdata: " + err.Error())
|
||||||
}
|
}
|
||||||
|
if err := container.SetUserData("comment", comment); err != nil {
|
||||||
|
srv.containers.Destroy(container)
|
||||||
|
return nil, errors.New("Error setting container userdata: " + err.Error())
|
||||||
|
}
|
||||||
return container, nil
|
return container, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,6 +593,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
fl_attach := flags.Bool("a", false, "Attach stdin and stdout")
|
fl_attach := flags.Bool("a", false, "Attach stdin and stdout")
|
||||||
fl_stdin := flags.Bool("i", false, "Keep stdin open even if not attached")
|
fl_stdin := flags.Bool("i", false, "Keep stdin open even if not attached")
|
||||||
fl_tty := flags.Bool("t", false, "Allocate a pseudo-tty")
|
fl_tty := flags.Bool("t", false, "Allocate a pseudo-tty")
|
||||||
|
fl_comment := flags.String("c", "", "Comment")
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := flags.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -601,7 +608,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
return errors.New("No such image: " + name)
|
return errors.New("No such image: " + name)
|
||||||
}
|
}
|
||||||
// Create new container
|
// Create new container
|
||||||
container, err := srv.CreateContainer(img, *fl_tty, *fl_stdin, cmd[0], cmd[1:]...)
|
container, err := srv.CreateContainer(img, *fl_tty, *fl_stdin, *fl_comment, cmd[0], cmd[1:]...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Error creating container: " + err.Error())
|
return errors.New("Error creating container: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue