Loading…
Warp is now open-source Learn more
Loading…
To remove (prune) all stopped Docker containers at once, you can use the following command:
$ docker container pruneIf you want to remove these containers without being prompted for confirmation, you can use the -f flag (short for force):
$ docker container prune -fIf you’re using Warp as your terminal and you need to quickly retrieve this command, you can use Warp's Workflows feature by pressing CTRL-SHIFT-R and typing remove stopped containers:

Then pressing ENTER to use the suggested command:

The docker container prune command offers the possibility to filter the containers that will be removed using the --filter flag.
To remove all stopped containers that were created before a certain time, you can use the until=<timestamp> filter, where timestamp can be a Unix timestamp, a date formatted timestamp, or Go duration string.
For example:
$ docker container prune --filter "until=10m"
$ docker container prune --filter "until=2023-01-15"The docker rm command is used to remove one or more stopped containers using their name or ID.
$ docker rm …
$ docker rm …To get a list of all stopped containers IDs – which are containers with a status equivalent to exited or dead – you can use the docker ps command combined with the --filter and the -q flags:
$ docker ps --filter "status=exited" --filter "status=dead" -qWhere:
To remove all stopped containers at once with docker rm, you can combine it with the previous docker ps command using the command substitution syntax:
$ docker rm $(docker ps --filter "status=exited" --filter "status=dead" -q)Where the expression contained in parenthesis $(expression) will be replaced by its result, which in this case will be the list of all stopped containers IDs.
A concise guide to learning Docker using Lazydocker. Highlights Docker’s benefits and takes advantage of Warp's AI features for a quick setup.
Learn how to launch and connect to a containerized SSH server in Docker using password-based authentication and SSH keys.
Learn how to remove a Docker image locally, on a Docker registry, and on Artifactory.
Learn how to override and customize the entrypoint of a Docker container using the docker run command.
Learn how to define and set build-time variables for Docker images using the ARG instruction and the --build-arg flag.
Learn how to start a new Docker container from an image in both the foreground and the background using the docker-run command.
How to gracefully shutdown running containers and forcefully kill unresponsive containers with signals in Docker using the docker-stop and docker-kill commands.
Learn how to set, change and match a docker container hostname.
Learn how define and pass environment variables to Docker containers using an .env file in Docker Compose.
Learn how to write and use .env files in Docker to populate the environment of containers on startup.
Learn how to restart Docker containers automatically with restart policies and manually using the docker restart, docker start, docker stop and docker kill commands.
Start an interactive shell in Docker container
$ docker container prune$ docker container prune -f$ docker container prune --filter "until=10m"
$ docker container prune --filter "until=2023-01-15"$ docker rm …
$ docker rm …$ docker ps --filter "status=exited" --filter "status=dead" -q$ docker rm $(docker ps --filter "status=exited" --filter "status=dead" -q)