โ†’ Docker provides several commands for managing containers and images. Below are some important commands that help you stop and delete containers and images effectively.

1. ๐Ÿ›‘ Stop All Running Containers โ‡’

To stop all running containers, you can use the following command:

docker stop $(docker ps -a -q)

Purpose: This command stops all running containers in a single command, saving time and effort if you have multiple containers running. โณ

2. ๐Ÿ—‘๏ธ Delete All Stopped Containers โ‡’

After stopping the containers, you might want to clean up by removing those containers that are no longer in use. The following command deletes all stopped containers:

docker rm $(docker ps -a -q)

Purpose: This command helps clean up your system by removing all containers that are not currently running. ๐Ÿงน

3. ๐Ÿ–ผ๏ธ Delete All Docker Images โ‡’

If you want to free up disk space by removing unused Docker images, use the following command:

docker rmi -f $(docker image -q)