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

Signed-off-by: Tzu-Jung Lee <roylee17@gmail.com>
Upstream-commit: b1a3a5580285b58d643ff0c09c263f78d1088f37
Component: engine
This commit is contained in:
Tzu-Jung Lee
2013-12-23 14:42:04 -08:00
parent ec888af3b0
commit c952ec0ff7

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