i2tutorials

Docker – Containers

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 

c1

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 ps

Syntax

$ docker ps 

Return Value

You’ll see a list of the containers that are running right now.

Example

$ docker ps

Output

As a result of the above command:

Here’s some more docker ps variations.

$ docker ps -a

Lists all the containers on the system with this command

Syntax

$ docker ps -a 

Options

Return Value

All containers will be displayed in the output.

Example

$ sudo docker ps -

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

Return Value

All commands run against that image will appear in the output.

Example

$ sudo docker history centos

It’ll show all the commands that were run against the centos  image.

Output

As a result of the above command:

 

Exit mobile version