Stop Docker Containers

Docker is well known for its containerized concept. The Docker containers are an essential part of the Docker platform that is utilized for building, deploying, and shipping applications. These containers pack the program dependencies and source code. While working with the Docker containers, developers are usually required to start and stop the Docker container. For this purpose, Docker containers are supported by various commands to provide different functionalities.

This blog will demonstrate how to stop Docker containers in Docker.

How to Stop Docker Containers?

While managing applications on Docker, users must create, start and stop Docker containers. For doing so, go through the provided instructions.

Step 1: Create Docker Container

First, create a Docker container with the help of a Docker image. To do so, check out the mentioned command. Here:

  • -i” flag creates the container in an interactive way.
  • -p” defines the port to execute the container.
  • –name” flag is utilized to define the name of the container.
  • dockerimage” is a Docker image used to create a Docker container:
> docker container create -i -p 8080:8080 --name docker-container dockerimage

Step 2: Start Docker Container

Next, start the container to execute it on a specified port using the “docker start” command:

> docker start docker-container

Next, navigate to the “localhost:<specified-port>” and check if the container is running or not. From the below output, you can see that we have successfully executed the container on port “8080”:

Step 3: Stop Docker Container

In order to stop the container in Docker, utilize the “docker stop container-name” command. However, users can also use container id instead of container name:

> docker stop docker-container

Container id can be viewed by listing all Docker containers:

> docker ps -a

Step 4: Stop All Containers in Docker

To stop all executing containers, go through the below-mentioned command. Here, “-a” is used to select all containers, and “-q” is utilized to display only container ids:

> docker stop $(docker ps -a -q)

This is all about how to stop the Docker containers in Docker.


To stop the running container of Docker, utilize the “docker stop <container-name>” command. Users can use container id as well to stop the container. In order to stop all running containers in Docker, utilize the “docker stop $(docker ps -a -q)” command. This blog has demonstrated how to stop the Docker containers in Docker.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.