# Working with Docker Containers from the command line

> Learn how to work with Docker containers from the command line, using docker ps to list them and docker container stop, rm, and inspect to manage them.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-07-16 | Topics: [Docker](https://flaviocopes.com/tags/docker/) | Canonical: https://flaviocopes.com/docker-containers-command-line/

The Docker Desktop application is awesome to work with containers locally via a graphical interface.

You are not required to use it. You can use the CLI commands.

The `docker ps` command lists the currently running containers:

![Terminal output showing docker ps command listing a running container named node-app with ID, status, and port mapping](https://flaviocopes.com/images/docker-containers-command-line/Screen_Shot_2020-07-05_at_12.31.24.png)

> This is the same as running `docker container ls`.

In this case, container with name `node-app` and ID `739037a911e0` generated from the image `examplenode`, created `4 minutes ago`, is up since 4 minutes, and the port 80 of the host machine is mapped to the container port 3000 using the TCP protocol.

When you know the contained ID, you can stop the container by running

```sh
docker container stop <ID>
```

![Terminal showing docker container stop command being executed to stop a running container](https://flaviocopes.com/images/docker-containers-command-line/Screen_Shot_2020-07-05_at_15.30.03.png)

Once a container is stopped, you can see it using `docker container ls -a`:

![Terminal output of docker container ls -a command showing stopped containers with Exited status](https://flaviocopes.com/images/docker-containers-command-line/Screen_Shot_2020-07-05_at_15.31.24.png)

And you can remove it using `docker container rm`:

```sh
docker container rm <ID>
```

You can inspect all the details about a container running `docker inspect`:

![Terminal displaying docker inspect command output showing detailed JSON configuration of a container](https://flaviocopes.com/images/docker-containers-command-line/Screen_Shot_2020-07-05_at_15.36.35.png)

Another useful CLI command is `docker info` which gives you lots of information about the current state of your Docker installation, including the number of containers and images.

![Terminal output of docker info command showing Docker installation details including containers, images, and server version](https://flaviocopes.com/images/docker-containers-command-line/Screen_Shot_2020-07-05_at_15.55.15.png)
