steampipe plugin install docker

Table: docker_container - Query Docker Containers using SQL

Docker Containers are a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. With Docker, you can manage your infrastructure in the same ways you manage your applications. It provides a consistent and reproducible environment isolated from other applications.

Table Usage Guide

The docker_container table provides insights into Docker Containers within Docker. As a DevOps engineer, explore container-specific details through this table, including the container's ID, image, command, created time, status, and more. Utilize it to uncover information about containers, such as those with specific configurations, the status of the containers, and the verification of container isolation.

Examples

List all containers

Explore all active containers in your Docker environment to manage and monitor your applications more effectively. This helps in identifying potential issues and understanding the overall status of your applications.

select
*
from
docker_container;
select
*
from
docker_container;

List running containers

Discover the segments that are actively running within your Docker environment. This can help you manage resources and troubleshoot issues more effectively.

select
id,
names
from
docker_container
where
state = 'running';
select
id,
names
from
docker_container
where
state = 'running';

Find a container by name

Discover the segments that correspond to a specific container name within your Docker environment. This allows you to quickly locate and analyze the details of a particular container, enhancing your overall management and oversight of your Docker resources.

select
*
from
docker_container
where
names ? '/practical_austin';
Error: SQLite does not support the '?' operator for JSON objects.

List containers which do not have a health check configured

Identify instances where Docker containers may lack a health check configuration. This is useful to ensure all containers are functioning correctly and to maintain optimal system health.

select
id,
names,
image,
command,
created
from
docker_container
where
config -> 'Healthcheck' is null;
select
id,
names,
image,
command,
created
from
docker_container
where
json_extract(config, '$.Healthcheck') is null;

List containers with host network namespace shared

Explore which Docker containers share the host's network namespace. This is useful for understanding potential security risks, as such containers have access to all network interfaces and services running on the host machine.

select
id,
names,
image,
command,
created
from
docker_container
where
inspect -> 'HostConfig' ->> 'NetworkMode' = 'host';
select
id,
names,
image,
command,
created
from
docker_container
where
json_extract(inspect, '$.HostConfig.NetworkMode') = 'host';

Control examples

Schema for docker_container

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
commandtextMain command running in the container.
configjsonbConfig contains the configuration data about a container.
createdtimestamp with time zoneTime when the container was created.
host_configjsonbHost configuration for the container.
idtextID of the container.
imagetextName of the image for the container.
image_idtextID of the image for the container.
inspectjsonbContainer Inspect returns the container information.
labelsjsonbLabels for the container.
mountsjsonbVolume mounts for the container.
namesjsonbNames assigned to the container.
network_settingsjsonbNetwork settings for the container.
portsjsonbPorts open for the container.
size_root_fsbigint
size_rwbigint
statetextState of the container: running, restarting, etc.
statustextStatus message from the container.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- docker

You can pass the configuration to the command with the --config argument:

steampipe_export_docker --config '<your_config>' docker_container