Forrest logo
back to the docker tool

docker:tldr:3d1e7

docker: Filter containers by exit status code.
$ docker ps --all --filter="exited=${code}"
try on your machine

The command "docker ps --all --filter="exited=${code}" is used to list all the Docker containers, including both running and exited containers, that match a specific exit code.

Let's break down the command:

  • "docker ps" is the basic command to list all containers. By default, it only shows the running containers.

  • "--all" flag extends the command to display all containers, including the ones that are not running. This includes containers that have exited.

  • "--filter" flag is used to filter the output based on specific criteria. In this case, we are filtering the containers based on their exit code.

  • "exited=${code}" is the filter expression where "${code}" should be replaced with the desired exit code, such as "0" for a successful exit or a specific error code. This expression filters the containers based on their exit code, showing only the ones that match the provided code.

So, running the command "docker ps --all --filter="exited=${code}" will list all Docker containers, whether they are running or exited, and filter the output to display only the containers that have exited with the specified exit code.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool