Search notes:

Docker containers

Identifying containers

A container is identified by an id that looks like ada3b521615d. Additionally, a container is given a random(?) name like adoring_babbage or nifty_cray.

Status of containers

The possible states of containers are

Exporting a container's file system

The file system of a container can be exported to a tar archive with docker export.

Removing old Docker containers

$ docker rm $(docker ps -q -f status=exited)
$ docker rm $(docker ps --no-trunc -aq)
With Docker 1.13.x:
$ docker container prune
See also the --rm option of docker run (which removes the a container right after executing the command in it).

Detaching and attaching again

$ docker run -it --name foo debian bash
root@aa4a579e2648:/# var=hello
<ctrl-p> <ctrl-q>
Container is detached.
Attach again:
$docker attach foo
root@aa4a579e2648:/# echo $var

See also

docker run creates a container and runs a command in it.
docker ps lists containers.

Index