Git Product home page Git Product logo

turbot / steampipe-plugin-docker Goto Github PK

View Code? Open in Web Editor NEW
8.0 10.0 0.0 319 KB

Use SQL to instantly query Dockerfile commands and more from Docker. Open source CLI. No DB required.

Home Page: https://hub.steampipe.io/plugins/turbot/docker

License: Apache License 2.0

Makefile 0.19% PLSQL 3.45% Go 96.37%
docker docker-api steampipe steampipe-plugin sql postgresql postgresql-fdw hacktoberfest backup etl sqlite zero-etl

steampipe-plugin-docker's Introduction

image

Docker Plugin for Steampipe

Use SQL to query Dockerfile configuration and more from Docker.

Quick start

Install the plugin with Steampipe:

steampipe plugin install docker

Configure your config file to include directories with Dockerfiles. If no directory is specified, the current working directory will be used.

Run steampipe:

steampipe query

Run a query:

select
  instruction,
  data
from
  dockerfile_instruction
order by
  start_line;

Engines

This plugin is available for the following engines:

Engine Description
Steampipe The Steampipe CLI exposes APIs and services as a high-performance relational database, giving you the ability to write SQL-based queries to explore dynamic data. Mods extend Steampipe's capabilities with dashboards, reports, and controls built with simple HCL. The Steampipe CLI is a turnkey solution that includes its own Postgres database, plugin management, and mod support.
Postgres FDW Steampipe Postgres FDWs are native Postgres Foreign Data Wrappers that translate APIs to foreign tables. Unlike Steampipe CLI, which ships with its own Postgres server instance, the Steampipe Postgres FDWs can be installed in any supported Postgres database version.
SQLite Extension Steampipe SQLite Extensions provide SQLite virtual tables that translate your queries into API calls, transparently fetching information from your API or service as you request it.
Export Steampipe Plugin Exporters provide a flexible mechanism for exporting information from cloud services and APIs. Each exporter is a stand-alone binary that allows you to extract data using Steampipe plugins without a database.
Turbot Pipes Turbot Pipes is the only intelligence, automation & security platform built specifically for DevOps. Pipes provide hosted Steampipe database instances, shared dashboards, snapshots, and more.

Developing

Prerequisites:

Clone:

git clone https://github.com/turbot/steampipe-plugin-docker.git
cd steampipe-plugin-docker

Build, which automatically installs the new version to your ~/.steampipe/plugins directory:

make

Configure the plugin:

cp config/* ~/.steampipe/config
vi ~/.steampipe/config/docker.spc

Try it!

steampipe query
> .inspect docker

Further reading:

Open Source & Contributing

This repository is published under the Apache 2.0 (source code) and CC BY-NC-ND (docs) licenses. Please see our code of conduct. We look forward to collaborating with you!

Steampipe is a product produced from this open source software, exclusively by Turbot HQ, Inc. It is distributed under our commercial terms. Others are allowed to make their own distribution of the software, but cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our Open Source FAQ.

Get Involved

Join #steampipe on Slack →

Want to help but don't know where to start? Pick up one of the help wanted issues:

steampipe-plugin-docker's People

Contributors

bigdatasourav avatar cbruno10 avatar dependabot[bot] avatar e-gineer avatar madhushreeray30 avatar misraved avatar parthai avatar subhajit97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

steampipe-plugin-docker's Issues

Using an aggregator produces inconsistent results

Describe the bug
When using an aggregator connection, e.g.,

connection "docker_local" {
  plugin = "docker"
}

connection "docker_remote" {
  plugin     = "docker"
  host       = "tcp://10.200.20.200:2376"
  cert_path  = "/Users/myuser/certs"
  tls_verify = true
}

# Aggregator
connection "docker_all" {
  plugin = "docker"
  type   = "aggregator"

  connections = ["docker_local", "docker_remote"]
}

Running the query produces inconsistent results:

select * from docker_all.docker_info;
Welcome to Steampipe v0.21.0-beta.4
For more information, type .help
> select * from docker_all.docker_info
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| architecture | bridge_nf_ip6_tables | bridge_nf_ip_tables | cgroup_driver | cgroup_version | containerd_commit                        | containers | containers_paused | containers_running | containers_stopped |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+

Time: 490ms. Rows fetched: 1. Hydrate calls: 0.
> .quit
cbruno@M1P ~ % steampipe query
Welcome to Steampipe v0.21.0-beta.4
For more information, type .help
> select * from docker_all.docker_info
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| architecture | bridge_nf_ip6_tables | bridge_nf_ip_tables | cgroup_driver | cgroup_version | containerd_commit                        | containers | containers_paused | containers_running | containers_stopped |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+

Time: 487ms. Rows fetched: 1. Hydrate calls: 0.
> .quit
cbruno@M1P ~ % steampipe query
Welcome to Steampipe v0.21.0-beta.4
For more information, type .help
> select * from docker_all.docker_info
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| architecture | bridge_nf_ip6_tables | bridge_nf_ip_tables | cgroup_driver | cgroup_version | containerd_commit                        | containers | containers_paused | containers_running | containers_stopped |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| aarch64      | true                 | true                | cgroupfs      | 2              | 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1 | 5          | 0                 | 0                  | 5                  |
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+

Time: 0.5s. Rows fetched: 1. Hydrate calls: 0.
> .quit
cbruno@M1P ~ % steampipe query
Welcome to Steampipe v0.21.0-beta.4
For more information, type .help
> select * from docker_all.docker_info
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| architecture | bridge_nf_ip6_tables | bridge_nf_ip_tables | cgroup_driver | cgroup_version | containerd_commit                        | containers | containers_paused | containers_running | containers_stopped |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| aarch64      | true                 | true                | cgroupfs      | 2              | 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1 | 5          | 0                 | 0                  | 5                  |
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+

Time: 493ms. Rows fetched: 1. Hydrate calls: 0.
> .quit
cbruno@M1P ~ % steampipe query
Welcome to Steampipe v0.21.0-beta.4
For more information, type .help
> select * from docker_all.docker_info
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| architecture | bridge_nf_ip6_tables | bridge_nf_ip_tables | cgroup_driver | cgroup_version | containerd_commit                        | containers | containers_paused | containers_running | containers_stopped |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+

Time: 498ms. Rows fetched: 1. Hydrate calls: 0.
> .quit
cbruno@M1P ~ % steampipe query
Welcome to Steampipe v0.21.0-beta.4
For more information, type .help
> select * from docker_all.docker_info
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| architecture | bridge_nf_ip6_tables | bridge_nf_ip_tables | cgroup_driver | cgroup_version | containerd_commit                        | containers | containers_paused | containers_running | containers_stopped |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+
| aarch64      | true                 | true                | cgroupfs      | 2              | 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1 | 5          | 0                 | 0                  | 5                  |
| x86_64       | true                 | true                | systemd       | 2              | 0cae528dd6cb557f7201036e9f43420650207b58 | 1          | 0                 | 0                  | 1                  |
+--------------+----------------------+---------------------+---------------+----------------+------------------------------------------+------------+-------------------+--------------------+--------------------+

Time: 0.5s. Rows fetched: 1. Hydrate calls: 0.

This may be due to the use of setting environment variables for use with the client (

dockerConfig := GetConfig(d.Connection)
if dockerConfig.Host != nil {
os.Setenv("DOCKER_HOST", *dockerConfig.Host)
}
if dockerConfig.APIVersion != nil {
os.Setenv("DOCKER_API_VERSION", *dockerConfig.APIVersion)
}
if dockerConfig.CertPath != nil {
os.Setenv("DOCKER_CERT_PATH", *dockerConfig.CertPath)
}
if dockerConfig.TLSVerify != nil {
if *dockerConfig.TLSVerify {
os.Setenv("DOCKER_TLS_VERIFY", "1")
} else {
os.Setenv("DOCKER_TLS_VERIFY", "0")
}
}
// Always load the docker config from ENV vars
conn, err := client.NewClientWithOpts(client.FromEnv)
), as Steampipe has a process per plugin, but environment variables are shared in each process

Steampipe version (steampipe -v)
v0.20.9

Plugin version (steampipe plugin list)
v0.9.0

To reproduce
See above.

Expected behavior
Queries with aggregator connections should work correctly

Additional context
We should use the other functions for creating clients if possible, e.g., https://github.com/moby/moby/blob/97e28de7e26639f768db29c96d2ab9c321a8f743/client/options.go#L137, and read in environment variables in the plugin code instead (but prefer config args).

enable environment variable substitution in git paths

Is your feature request related to a problem? Please describe.
Yes. I'm using the docker plugin to look at dockerfiles stored in multiple git repos. I have the feature working with the following from docker.spc

paths = [
"git::ssh://[email protected]:999/foo/repo1.git//docker//Dockerfile?ref=master&depth=1&sshkey=base64_of_my_private_ssh_key"
]

Obviously this uses features directly from go-getter but its working fine (v0.5.1. of the docker plugin and 0.18.1 of steampipe).

Now when I try using an environment variable to store the base64 of my private ssh key e.g.

paths = [
"git::ssh://[email protected]:999/an/repo1.git//docker//Dockerfile?ref=master&depth=1&sshkey="
]

(I'm following the syntax from the example usingAWS environment variables)

then I start the steampipe container like this...

docker run
-p 9193:9193
-d
--name steampipe
-e SSHKEY=base64_of_my_private_ssh_key
...

When I do a sql query from dockerfile_instruction table unfortunately I get the following error:

SQL Error [HV000]: ERROR: rpc error: code = Unknown desc = failed to get directory specified by the source git::ssh://[email protected]:999/foo/repo1.git//docker?depth=1&ref=master&sshkey=%253CSSHKEY%253E: error downloading 'ssh://[email protected]:999/foo/repo1.git?depth=1&ref=master&sshkey=redacted': illegal base64 data at input byte 0

Describe the solution you'd like
I'd like to be able to use an environment variable to store the base64 of my private ssh key when querying dockerfiles in git.

Describe alternatives you've considered
Just repeat the base64 encoded ssh key in every path in the .spc. But this is suboptimal.

Additional context
I don't think this is a problem specific to the docker plugin, but probably all plugins which use go-getter

Add File Watcher support for `paths` argument in docker config

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Update the query examples in the docs/index.md and README files

Describe the bug
The example queries use dockerfile_cmd table which doesn't exist. Instead, we need to replace it with dockerfile_instruction

Steampipe version (steampipe -v)
Example: v0.15.3

Plugin version (steampipe plugin list)
Example: v0.3.1

To reproduce

  1. Running the example query produces the following error -
select
  cmd,
  args
from
  dockerfile_cmd
where
  path = '/var/lib/docker';
Error: relation "dockerfile_cmd" does not exist (SQLSTATE 42P01)

Expected behavior
We should use the correct query to get the results

Additional context
Add any other context about the problem here.

Compile the plugin with `steampipe-plugin-sdk/v5`

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Update plugin hub home page query with correct query

Describe the bug
Table dockerfile_cmd is not available in the tables list. It should probably be updated with the below query

select
  instruction,
  data
from
  dockerfile_instruction
where
  path = '/my/Dockerfile';

image

Add table docker_run

Add ability to run docker container.
Currently I'm using the exec plugin to run docker containers, e.g.

select * from exec_local.exec_command where command='docker run --rm ubuntu -- uname -a'

A new table docker_run may do the same like this

select * from docker_run where image='ubuntu' and command='name -a`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.