mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-03 15:28:35 +00:00
Using names in docker ps --since-id/--before-id, resolves #3565
Also renames --since-id/--before-id to --since/--before and add errors on non-existent containers. Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
+20
-3
@@ -981,12 +981,27 @@ func (srv *Server) Containers(job *engine.Job) engine.Status {
|
||||
return nil
|
||||
}, -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() {
|
||||
if !container.State.IsRunning() && !all && n <= 0 && since == "" && before == "" {
|
||||
continue
|
||||
}
|
||||
if before != "" && !foundBefore {
|
||||
if container.ID == before || utils.TruncateID(container.ID) == before {
|
||||
if container.ID == beforeCont.ID {
|
||||
foundBefore = true
|
||||
}
|
||||
continue
|
||||
@@ -994,8 +1009,10 @@ func (srv *Server) Containers(job *engine.Job) engine.Status {
|
||||
if n > 0 && displayed == n {
|
||||
break
|
||||
}
|
||||
if container.ID == since || utils.TruncateID(container.ID) == since {
|
||||
break
|
||||
if since != "" {
|
||||
if container.ID == sinceCont.ID {
|
||||
break
|
||||
}
|
||||
}
|
||||
displayed++
|
||||
out := &engine.Env{}
|
||||
|
||||
Reference in New Issue
Block a user