Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ps command doesn't work in docker container

Tags:

docker

debian

I want to do a ps command in a docker container derived from Debian official Docker hub repository:

$ docker run -ti debian:wheezy /bin/bash root@51afd6b09af8:/# ps bash: ps: command not found 
like image 227
Yves Nicolas Avatar asked Nov 17 '14 21:11

Yves Nicolas


People also ask

What is ps in docker command?

The docker ps command, which is available inside the container, is used to see the status of the process. This is similar to the standard ps command in the Linux environment and is not a docker ps command that we run on the Docker host machine.

What is the use of docker command docker ps A?

The 'docker ps' is a Docker command to list the running containers by default; however, we can use different flags to get the list of other containers that are in stopped or exited status. We can also manipulate the output as per our requirement using flags.

What is the difference between docker ps and docker ps?

There is no difference between the docker ps (docker process status) and docker container ls (docker container list) commands in terms of functionality. They even allow the same set of flags. The only real difference between the two is the fact that the latter is newer and more verbose than the former.

What is docker ps status?

docker ps is a command that every docker user uses. This command basically shows the container status. In case someone doesn't know Docker Image is just file contents on the disk and Docker container is a running image which is a standalone process. So this docker ps stands for process status.

What is Docker ps command?

As the UNIX ps command is used to show processes (programs that are being executed), Docker behaves similarly. Running docker ps will only show the docker containers that are active. If you stop a running container, it still exists, only that it is not running anymore.

How to show running containers in Docker psonly?

docker psonly shows running containers while passing the -aflag shows all containers. If you want your container to show up, you will have to start it by using docker container start Share Follow answered Feb 12, 2020 at 12:34

How to manipulate the output of a docker container?

We can also manipulate the output as per our requirement using flags. Docker has used the naming convention of ps from Linux; ps means ‘process status’ in Linux, and containers are actually running as a process on the Linux server; that’s why ‘docker ps’ is used to list the containers.

Does Docker help still work?

However, docker help and docker version still work. I think there is something like a deadlock with a particular container, so commands related to containers won't complete. How to handle such a situation ?


2 Answers

ps is not installed in the base wheezy image. Try this from within the container:

apt-get update && apt-get install procps 

or add the following line to the Dockerfile:

RUN apt-get update && apt-get install -y procps && rm -rf /var/lib/apt/lists/* 
like image 192
user2105103 Avatar answered Oct 16 '22 21:10

user2105103


use docker top

docker top <container ID> 
like image 30
es cologne Avatar answered Oct 16 '22 20:10

es cologne