Docker Container – Everything You Need to Know

onestop_databy:

Docker

This tutorial shows how to list, restart stop, and remove a container. In case you want to learn more about Docker, please check these two tutorials:

Docker: 7 Essential Things to Get Started, and Docker Tricks to Remove All Images.

1. List a Docker Container

Below is the syntax of how to list the docker containers. See below:

# syntax
$ docker list

It should list something like this

CONTAINER ID        IMAGE                              COMMAND             CREATED             STATUS              PORTS               NAMES
6fdf16de1316        onestopdataanalysis/crass:latest   "/bin/bash"         7 seconds ago       Up 6 seconds                            unruffled_proskuriakova

2. Restart a Docker Container

The syntax on how to restart a container is very simple and will delete the targeted container or a set of containers.

# syntax
$ docker restart $CONTAINER_ID_1 $CONTAINER_ID_2 $CONTAINER_ID_n

#real example
$ docker restart 6fdf16de1316

3. Stop a Docker Container

The syntax on how to stop a container is very simple and will delete the targeted container or a set of containers.

# syntax
$ docker stop $CONTAINER_ID_1 $CONTAINER_ID_2 $CONTAINER_ID_n

#real example
$ docker stop 6fdf16de1316

4. Remove a Container

The syntax on how to remove a container is very simple and will delete the targeted container or a set of containers.

# syntax
$ docker rm $CONTAINER_ID_1 $CONTAINER_ID_2 $CONTAINER_ID_n

#real example
$ docker rm 6fdf16de1316

More Resources

Here are two of my favorite Docker Books in case you want to learn more about it.

Related Posts