Docker - Containers

> Virtualization - (Virtual Machine|Container) > Docker

1 - About

VM - Container (Ligthweight VM) in Docker.

A container is a running instance of an image.

Docker containers only run as long as the command you specify is active.


3 - Properties

3.1 - Id

A container ID uniquely identifies a container.

A container ID has two versions:

  • a long variant: 3e3a1ac2c76e447542b99de6db704629e414a674301c520687a7dc13a841746d
  • a shorter variant: 3e3a1ac2c76e

By running bash on the Ubuntu Image,

$ docker run -t -i ubuntu bash

You can see the container id in the prompt (here: c94698e7ab68)

[email protected]:/#

You can get a container Id by name with:

docker container ls -qf name=containerName

3.2 - Name

A container acquire a name:

  • via the -name parameter of the run command.
  • or automatically if not given (ie generated)

3.3 - Type

The daemon cannot run the two type of container. Therefore you need to switch the daemon by switching the type of containers. Example with docker for windows

4 - Management

4.1 - Create

4.2 - Start

4.3 - List

4.3.1 - Running

The ''docker ps'' command queries the Docker daemon for information about all the containers it knows about. See Docker - ps (List containers)

4.3.2 - All

Docker - info gives also information:

docker info
Containers: 9                                                                                    
 Running: 1                                                                                      
 Paused: 0                                                                                       
 Stopped: 8

4.4 - Logs

4.5 - Stop

4.6 - Kill

docker kill - Kill one or more running containers

4.7 - Diff

A list of files created or modified sinds a docker run. Inspect changes on a container's filesystem

docker diff container_name

4.8 - Restart

The docker restart command that runs a stop and then start on the container.

4.9 - Remove


Remove one or more containers


  • -f, –force Force the removal of a running container (uses SIGKILL)
  • –help Print usage
  • -l, –link Remove the specified link
  • -v, –volumes Remove the volumes associated with the container

4.10 - Configuration and status information (IP, ...)

4.11 - Process