mirror of https://github.com/docker/docs.git
Merge pull request #4744 from LK4D4/fix_issue_#3565
Using names in docker ps --since-id/--before-id, resolves #3565
This commit is contained in:
commit
22c18de7be
|
|
@ -1337,8 +1337,8 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
||||||
all := cmd.Bool([]string{"a", "-all"}, false, "Show all containers. Only running containers are shown by default.")
|
all := cmd.Bool([]string{"a", "-all"}, false, "Show all containers. Only running containers are shown by default.")
|
||||||
noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
|
noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
|
||||||
nLatest := cmd.Bool([]string{"l", "-latest"}, false, "Show only the latest created container, include non-running ones.")
|
nLatest := cmd.Bool([]string{"l", "-latest"}, false, "Show only the latest created container, include non-running ones.")
|
||||||
since := cmd.String([]string{"#sinceId", "-since-id"}, "", "Show only containers created since Id, include non-running ones.")
|
since := cmd.String([]string{"#sinceId", "#-since-id", "-since"}, "", "Show only containers created since Id or Name, include non-running ones.")
|
||||||
before := cmd.String([]string{"#beforeId", "-before-id"}, "", "Show only container created before Id, include non-running ones.")
|
before := cmd.String([]string{"#beforeId", "#-before-id", "-before"}, "", "Show only container created before Id or Name, include non-running ones.")
|
||||||
last := cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running ones.")
|
last := cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running ones.")
|
||||||
|
|
||||||
if err := cmd.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -392,11 +392,8 @@ _docker_port()
|
||||||
_docker_ps()
|
_docker_ps()
|
||||||
{
|
{
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--since-id|--before-id)
|
--since|--before)
|
||||||
COMPREPLY=( $( compgen -W "$( __docker_q ps -a -q )" -- "$cur" ) )
|
__docker_containers_all
|
||||||
# TODO replace this with __docker_containers_all
|
|
||||||
# see https://github.com/dotcloud/docker/issues/3565
|
|
||||||
return
|
|
||||||
;;
|
;;
|
||||||
-n)
|
-n)
|
||||||
return
|
return
|
||||||
|
|
@ -407,7 +404,7 @@ _docker_ps()
|
||||||
|
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "-q --quiet -s --size -a --all --no-trunc -l --latest --since-id --before-id -n" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "-q --quiet -s --size -a --all --no-trunc -l --latest --since --before -n" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -154,13 +154,13 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from port' -a '(__fish_print
|
||||||
# ps
|
# ps
|
||||||
complete -c docker -f -n '__fish_docker_no_subcommand' -a ps -d 'List containers'
|
complete -c docker -f -n '__fish_docker_no_subcommand' -a ps -d 'List containers'
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s a -l all -d 'Show all containers. Only running containers are shown by default.'
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s a -l all -d 'Show all containers. Only running containers are shown by default.'
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -l before-id -d 'Show only container created before Id, include non-running ones.'
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -l before -d 'Show only container created before Id or Name, include non-running ones.'
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s l -l latest -d 'Show only the latest created container, include non-running ones.'
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s l -l latest -d 'Show only the latest created container, include non-running ones.'
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s n -d 'Show n last created containers, include non-running ones.'
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s n -d 'Show n last created containers, include non-running ones.'
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -l no-trunc -d "Don't truncate output"
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -l no-trunc -d "Don't truncate output"
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s q -l quiet -d 'Only display numeric IDs'
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s q -l quiet -d 'Only display numeric IDs'
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s s -l size -d 'Display sizes'
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -s s -l size -d 'Display sizes'
|
||||||
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -l since-id -d 'Show only containers created since Id, include non-running ones.'
|
complete -c docker -A -f -n '__fish_seen_subcommand_from ps' -l since -d 'Show only containers created since Id or Name, include non-running ones.'
|
||||||
|
|
||||||
# pull
|
# pull
|
||||||
complete -c docker -f -n '__fish_docker_no_subcommand' -a pull -d 'Pull an image or a repository from the docker registry server'
|
complete -c docker -f -n '__fish_docker_no_subcommand' -a pull -d 'Pull an image or a repository from the docker registry server'
|
||||||
|
|
|
||||||
|
|
@ -967,13 +967,13 @@ new output from the container's stdout and stderr.
|
||||||
List containers
|
List containers
|
||||||
|
|
||||||
-a, --all=false: Show all containers. Only running containers are shown by default.
|
-a, --all=false: Show all containers. Only running containers are shown by default.
|
||||||
--before-id="": Show only container created before Id, include non-running ones.
|
--before="": Show only container created before Id or Name, include non-running ones.
|
||||||
-l, --latest=false: Show only the latest created container, include non-running ones.
|
-l, --latest=false: Show only the latest created container, include non-running ones.
|
||||||
-n=-1: Show n last created containers, include non-running ones.
|
-n=-1: Show n last created containers, include non-running ones.
|
||||||
--no-trunc=false: Don't truncate output
|
--no-trunc=false: Don't truncate output
|
||||||
-q, --quiet=false: Only display numeric IDs
|
-q, --quiet=false: Only display numeric IDs
|
||||||
-s, --size=false: Display sizes, not to be used with -q
|
-s, --size=false: Display sizes, not to be used with -q
|
||||||
--since-id="": Show only containers created since Id, include non-running ones.
|
--since="": Show only containers created since Id or Name, include non-running ones.
|
||||||
|
|
||||||
|
|
||||||
Running ``docker ps`` showing 2 linked containers.
|
Running ``docker ps`` showing 2 linked containers.
|
||||||
|
|
|
||||||
|
|
@ -981,12 +981,27 @@ func (srv *Server) Containers(job *engine.Job) engine.Status {
|
||||||
return nil
|
return nil
|
||||||
}, -1)
|
}, -1)
|
||||||
|
|
||||||
|
var beforeCont, sinceCont *runtime.Container
|
||||||
|
if before != "" {
|
||||||
|
beforeCont = srv.runtime.Get(before)
|
||||||
|
if beforeCont == nil {
|
||||||
|
return job.Error(fmt.Errorf("Could not find container with name or id %s", before))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if since != "" {
|
||||||
|
sinceCont = srv.runtime.Get(since)
|
||||||
|
if sinceCont == nil {
|
||||||
|
return job.Error(fmt.Errorf("Could not find container with name or id %s", since))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, container := range srv.runtime.List() {
|
for _, container := range srv.runtime.List() {
|
||||||
if !container.State.IsRunning() && !all && n <= 0 && since == "" && before == "" {
|
if !container.State.IsRunning() && !all && n <= 0 && since == "" && before == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if before != "" && !foundBefore {
|
if before != "" && !foundBefore {
|
||||||
if container.ID == before || utils.TruncateID(container.ID) == before {
|
if container.ID == beforeCont.ID {
|
||||||
foundBefore = true
|
foundBefore = true
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
|
@ -994,8 +1009,10 @@ func (srv *Server) Containers(job *engine.Job) engine.Status {
|
||||||
if n > 0 && displayed == n {
|
if n > 0 && displayed == n {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if container.ID == since || utils.TruncateID(container.ID) == since {
|
if since != "" {
|
||||||
break
|
if container.ID == sinceCont.ID {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
displayed++
|
displayed++
|
||||||
out := &engine.Env{}
|
out := &engine.Env{}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue