Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to List, Start and Stop Docker Containers

The main Docker commands to see, run and stop your containers.

VPS and Cloud Servers2 min read5 screenshots

List containers

Show the running containers:

docker ps
Listing the running containers

Show all containers, including stopped ones:

sudo docker ps -a
Listing all containers

Show only the container IDs:

sudo docker ps -aq
Listing only the IDs

You can filter the list, for example docker ps --filter "status=exited".

Start a container

Start an existing, stopped container:

docker start <container_id_or_name>
Starting a container

Create and start a new container from an image:

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Example, with a name:

docker run --name=Ubuntu_Docker ubuntu:22.04

Useful options: -d runs it in the background, -p 8080:80 publishes a port, and -it opens an interactive terminal.

Stop a container

docker stop <container_id_or_name>
Stopping a container

docker stop sends a stop signal and waits 10 seconds before it kills the container. Change the wait time:

docker stop --time=20 <container_id>

Force it to stop at once:

docker kill <container_id>

Stop all running containers:

docker stop $(docker ps -q)

Restart a container:

docker restart <container_id>

Remove a stopped container:

docker rm <container_id>

Why manage containers well

  • Free CPU, memory and disk on the server.
  • Keep the system tidy and easy to debug.
  • Avoid conflicts between ports and names.
  • Improve security by stopping what you do not use.

FAQ

What is Docker? A platform that packs apps and their dependencies in containers.

How do I list containers? docker ps for running ones, docker ps -a for all.

How do I start a container? docker start NAME for an existing one, docker run IMAGE for a new one.

How do I stop a container? docker stop NAME.

Quick recap

  • docker ps -a, docker start, docker stop.