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
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.
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.
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.
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.
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.
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
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.
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 ?
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/*
use docker top
docker top <container ID>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With