docker-top: improve error message for non-running containers

Signed-off-by: Tzu-Jung Lee <roylee17@gmail.com>
This commit is contained in:
Tzu-Jung Lee 2013-12-23 14:42:04 -08:00
parent 3fe4d5477a
commit b1a3a55802
1 changed files with 3 additions and 0 deletions

View File

@ -698,6 +698,9 @@ func (srv *Server) ImageHistory(name string) ([]APIHistory, error) {
func (srv *Server) ContainerTop(name, psArgs string) (*APITop, error) {
if container := srv.runtime.Get(name); container != nil {
if !container.State.IsRunning() {
return nil, fmt.Errorf("Container %s is not running", name)
}
pids, err := utils.GetPidsForContainer(container.ID)
if err != nil {
return nil, err