Docker

How to Stop All Docker Services?

Docker is a software forum that permits users to build, run and manage applications using containers. Docker provides many tools and services to create and deploy containers as well as to manage their lifecycle. Docker services are responsible for organizing Docker images and containers on the system. Moreover, users can stop the Docker services for saving resources, troubleshooting, upgrading, or maintenance.

This write-up will illustrate the step-by-step procedure to stop all Docker services.

How to Stop All Docker Services?

To stop all the Docker services including the Docker Engine and all the running containers, first, launch Command Prompt or Windows PowerShell as an administrator. Then, execute the “docker stop $(docker ps -a -q)” or “net stop docker” command to stop all Docker services. Follow the given-provided steps to do so.

Step 1: Launch “Windows PowerShell”

First, search for “Windows PowerShell” in the Start menu, and run it with administrator privileges:

It navigates to the terminal of Windows PowerShell.

Step 2: Stop Docker Services

To stop all the Docker services running on the system, execute the “docker stop $(docker ps -a -q)” command. Here, the “-a” flag is used to list all the Docker containers, and the “-q” option is utilized to display only the container’s ID in the output:

docker stop $(docker ps -a -q)

In the above image, all the IDs of the Docker containers can be seen that have been stopped.

Moreover, you can also stop all the Docker services in PowerShell. To do so, run the following command:

net stop docker

The above screenshot shows that the Docker Engine service has been stopped successfully.

Bonus Tip: Remove all Docker Containers

Users can also remove all Docker containers. To do so, utilize the following command:

docker rm $(docker ps -a -q)

This command has removed all stopped containers, so use it with caution.

Note: Keep in mind that stopping all Docker services may cause data loss or disruption of running applications, so be sure to back up any important data before executing these commands.

Conclusion

To stop all the Docker services including the Docker Engine and all the running containers, execute the “docker stop $(docker ps -a -q)” command in the terminal. To stop Docker services in PowerShell, use the “net stop docker” command. This write-up illustrated the step-by-step procedure to stop all Docker services.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.