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.
Properties
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)
root@c94698e7ab68:/#
You can get a container Id by name with:
docker container ls -qf name=containerName
10aca1bd6d00
Name
A container acquire a name:
- via the -name parameter of the run command.
- or automatically if not given (ie generated)
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
Version
The build version with inspect.
docker inspect -f '{{ index .Config.Labels "build_version" }}' <container_name>
Management
Create
- docker run Create a new container with a start command
Start
- docker run Create a new container with a start command
- docker start Start one or more stopped containers
List
Running
The docker ps']]' command queries the Docker daemon for information about all the containers it knows about. See Docker - ps (List containers)
=== All ===
Docker - info gives also information:
Containers: 9
Running: 1
Paused: 0
Stopped: 8
==== Logs ==== See Docker - logs of a container ==== Stop ==== Docker - Stop (a container) ==== Kill ==== docker kill - Kill one or more running containers ==== Diff ==== A list of files created or modified sinds a docker run. Inspect changes on a container's filesystem
docker diff container_name==== Restart ==== The docker restart command that runs a stop and then start on the container. ==== Remove ====
docker rm [OPTIONS] CONTAINER [CONTAINER…]Remove one or more containers Options: * -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 ==== Configuration and status information (IP, …)==== Docker - Inspect ==== Process ==== Docker - Top (Process)