Docker Containers
Containers are Docker images that can be run using the Docker run command. Docker’s basic purpose is to run containers.
Setting up a container
You run containers with Docker run. To run a container interactively, launch the Docker container first.
$ sudo docker run –itd centos /bin/bash - Press Ctrl+d or exit will take you back to your OS shell.

On the Ubuntu server, you will be running CentOS.
Container listing
Using the docker ps command, you can list all the containers running on the machine.
$ docker psSyntax
$ docker ps Return Value
You’ll see a list of the containers that are running right now.
Example
$ docker psOutput
As a result of the above command:

Here’s some more docker ps variations.
$ docker ps -aLists all the containers on the system with this command
Syntax
$ docker ps -a Options
- ─a − This tells the docker ps command to list all the containers.
Return Value
All containers will be displayed in the output.
Example
$ sudo docker ps -a
Output
As a result of the above command:

docker history
Using this command, you can see all the commands run with an image.
Syntax
$ docker history ImageID Options
- ImageID − The image ID you want to see all the commands run on.
Return Value
All commands run against that image will appear in the output.
Example
$ sudo docker history centosIt’ll show all the commands that were run against the centos image.
Output
As a result of the above command:
