turbot/docker

steampipe plugin install dockersteampipe plugin install docker

Table: dockerfile_instruction

List and query instructions from Dockerfile's.

Examples

List instructions in a specific Dockerfile

Set the path column to query a specific Dockerfile. A full path must be provided.

select
*
from
dockerfile_instruction
where
path = '/full/path/to/Dockerfile'
order by
start_line

List all Dockerfiles matched in the paths config

The paths config parameter sets directories (including wildcards) to search for Dockerfiles. To match, either the filename is Dockerfile (e.g. Dockerfile, Dockerfile.example), or the extension is .dockerfile (e.g. nginx.dockerfile).

select
*
from
dockerfile_instruction
order by
path,
start_line

List base images

select
path,
start_line,
data ->> 'image' as image,
data ->> 'tag' as tag
from
dockerfile_instruction as cmd
where
cmd.cmd = 'from'
order by
path,
start_line,
image,
tag

Find all exposed ports

select
path,
start_line,
(p ->> 'port')::int as port,
p ->> 'protocol' as protocol
from
dockerfile_instruction as cmd,
jsonb_array_elements(data) as p
where
cmd.cmd = 'expose'
order by
path,
start_line,
port,
protocol

.inspect dockerfile_instruction

List all instructions from the Dockerfile.

NameTypeDescription
argsjsonbArray of arguments passed to the command.
datajsonbCommand data, parsed into a convenient format for each command type.
end_linebigintLast line number of this cmd in the file.
flagsjsonbFlags passed to the command.
instructiontextCommand name in lowercase form, e.g. from, env, run, etc.
pathtextFull path of the file.
prev_commentjsonbComment above the command in the Dockerfile.
sourcetextFull original source code of the cmd.
stagetextStage name in the Dockerfile, defaults to the stage number.
stage_numberbigintStage number in the Dockerfile, starting at zero.
start_linebigintFirst line number of this cmd in the file.
sub_instructiontextSub command name in lowercase form, e.g. set to 'run' for 'onbuild run ...'.