Docker is supported on the following 64-bit versions of Ubuntu Linux: Ubuntu Xenial 16.04 (LTS) Ubuntu Wily 15.10; Ubuntu Trusty 14.04 (LTS) Ubuntu Precise 12.04 (LTS) A couple of notes: The following instructions involve installation using Docker packages only, and this ensures obtaining the latest official release of Docker.
Estimated reading time: 14 minutesUbuntu 12.04.3 LTS (Precise Pangolin) Select an image. Ubuntu is distributed on eight types of images described below. The desktop CD allows you to try. Dcb9 / ubuntu-12.04-LTS-install-docker. Last active Jun 21, 2021. Star 12 Fork 5 Star Code Revisions 7 Stars 12 Forks 5. What would you like to do? With Docker,a singlecommandsuchas“docker run -it ubuntu bash” will pull Ubuntu packages. “ubuntu:latest” or “ubuntu:12.04”). Second, images naturally. Debian and Ubuntu. Docker runs on: Ubuntu Xenial 16.04 LTS; Ubuntu Wily 15.10; Ubuntu Trusty 14.04 LTS; Ubuntu Precise 12.04 LTS; Debian testing stretch; Debian 8.0 Jessie; Debian 7.0 Wheezy (you must enable backports) Debian Wheezy. If so, you need to enable backports (if not, ignore this section).
Description
List containers
Usage
Options
Name, shorthand | Default | Description |
--all , -a | Show all containers (default shows just running) | |
--filter , -f | Filter output based on conditions provided | |
--format | Pretty-print containers using a Go template | |
--last , -n | -1 | Show n last created containers (includes all states) |
--latest , -l | Show the latest created container (includes all states) | |
--no-trunc | Don’t truncate output | |
--quiet , -q | Only display numeric IDs | |
--size , -s | Display total file sizes |
Parent command
Command | Description |
---|---|
docker | The base command for the Docker CLI. |
Examples
Prevent truncating output
Running docker ps --no-trunc
showing 2 linked containers.
Show both running and stopped containers
The docker ps
command only shows running containers by default. To see allcontainers, use the -a
(or --all
) flag:
docker ps
groups exposed ports into a single range if possible. E.g., acontainer that exposes TCP ports 100, 101, 102
displays 100-102/tcp
inthe PORTS
column.
Filtering
The filtering flag (-f
or --filter
) format is a key=value
pair. If there is morethan one filter, then pass multiple flags (e.g. --filter 'foo=bar' --filter 'bif=baz'
)
The currently supported filters are:
Filter | Description |
---|---|
id | Container’s ID |
name | Container’s name |
label | An arbitrary string representing either a key or a key-value pair. Expressed as <key> or <key>=<value> |
exited | An integer representing the container’s exit code. Only useful with --all . |
status | One of created , restarting , running , removing , paused , exited , or dead |
ancestor | Filters containers which share a given image as an ancestor. Expressed as <image-name>[:<tag>] , <image id> , or <[email protected]> |
before or since | Filters containers created before or after a given container ID or name |
volume | Filters running containers which have mounted a given volume or bind mount. |
network | Filters running containers connected to a given network. |
publish or expose | Filters containers which publish or expose a given port. Expressed as <port>[/<proto>] or <startport-endport>/[<proto>] |
health | Filters containers based on their healthcheck status. One of starting , healthy , unhealthy or none . |
isolation | Windows daemon only. One of default , process , or hyperv . |
is-task | Filters containers that are a “task” for a service. Boolean option (true or false ) |
label
The label
filter matches containers based on the presence of a label
alone or a label
and avalue.
The following filter matches containers with the color
label regardless of its value.
The following filter matches containers with the color
label with the blue
value.
name
The name
filter matches on all or part of a container’s name.
The following filter matches all containers with a name containing the nostalgic_stallman
string.
You can also filter for a substring in a name as this shows:
exited
The exited
filter matches containers by exist status code. For example, tofilter for containers that have exited successfully:
Filter by exit signal
You can use a filter to locate containers that exited with status of 137
meaning a SIGKILL(9)
killed them.
Any of these events result in a 137
status:
- the
init
process of the container is killed manually docker kill
kills the container- Docker daemon restarts which kills all running containers
status
The status
filter matches containers by status. You can filter usingcreated
, restarting
, running
, removing
, paused
, exited
and dead
. For example,to filter for running
containers:
To filter for paused
containers:
ancestor
The ancestor
filter matches containers based on its image or a descendant ofit. The filter supports the following image representation:
image
image:tag
image:[email protected]
short-id
full-id
If you don’t specify a tag
, the latest
tag is used. For example, to filterfor containers that use the latest ubuntu
image:
Match containers based on the ubuntu-c1
image which, in this case, is a childof ubuntu
:
Match containers based on the ubuntu
version 12.04.5
image:
The following matches containers based on the layer d0e008c6cf02
or an imagethat have this layer in its layer stack.
Create time
before
Docker Ubuntu 12.04
The before
filter shows only containers created before the container withgiven id or name. For example, having these containers created:
Filtering with before
would give:
Docker Ubuntu 12.04 64-bit
since
The since
filter shows only containers created since the container with givenid or name. For example, with the same containers as in before
filter:
volume
The volume
filter shows only containers that mount a specific volume or havea volume mounted in a specific path:
network
The network
filter shows only containers that are connected to a network witha given name or id.
The following filter matches all containers that are connected to a networkwith a name containing net1
.
The network filter matches on both the network’s name and id. The followingexample shows all containers that are attached to the net1
network, usingthe network id as a filter;
publish and expose
The publish
and expose
filters show only containers that have published or exposed port with a given portnumber, port range, and/or protocol. The default protocol is tcp
when not specified.
The following filter matches all containers that have published port of 80:
The following filter matches all containers that have exposed TCP port in the range of 8000-8080
:
Docker Ubuntu 12.04 Iso
The following filter matches all containers that have exposed UDP port 80
:
Formatting
The formatting option (--format
) pretty-prints container output using a Gotemplate.
Valid placeholders for the Go template are listed below:
Placeholder | Description |
---|---|
.ID | Container ID |
.Image | Image ID |
.Command | Quoted command |
.CreatedAt | Time when the container was created. |
.RunningFor | Elapsed time since the container was started. |
.Ports | Exposed ports. |
.Status | Container status. |
.Size | Container disk size. |
.Names | Container names. |
.Labels | All labels assigned to the container. |
.Label | Value of a specific label for this container. For example '{{.Label 'com.docker.swarm.cpu'}}' |
.Mounts | Names of the volumes mounted in this container. |
.Networks | Names of the networks attached to this container. |
When using the --format
option, the ps
command will either output the dataexactly as the template declares or, when using the table
directive, includescolumn headers as well.
The following example uses a template without headers and outputs the ID
andCommand
entries separated by a colon for all running containers:
To list all running containers with their labels in a table format you can use: