Giter VIP home page Giter VIP logo

Comments (8)

chris-rock avatar chris-rock commented on May 17, 2024

Can you open the inspec shell via inspec shell and run docker.containers.running?.ids?

from cis-docker-benchmark.

chris-rock avatar chris-rock commented on May 17, 2024

Seems to be a bug in inspec

from cis-docker-benchmark.

kidbrax avatar kidbrax commented on May 17, 2024

Sure, this is what I get:

Welcome to the interactive InSpec Shell
To find out how to use it, type: help

You are currently running on:

    OS platform:  amazon
    OS family:  amazon
    OS release: 2016.09

inspec> docker
=> Docker Host
inspec> docker.containers
=> #<Inspec::Resources::DockerContainerFilter:0x0000000233f480 @containers=[{}]>
inspec> docker.containers.running?
=> #<Inspec::Resources::DockerContainerFilter:0x0000000221d610> with status downcase start_with? "up"
inspec> docker.containers.running?.ids
=> []

from cis-docker-benchmark.

jdel avatar jdel commented on May 17, 2024

I am running into the same issue with a docker container I built based on chef/inspec where I just add the docker client:

Dockerfile

FROM chef/inspec:1.23.0

RUN apk add --update docker \
 && rm -rf /usr/bin/docker-* /usr/bin/dockerd \
 && rm -rf /var/cache/apk/*

I am running the container and bind mount my docker socket and get the same error as described:

docker run -ti --rm --name inspec -v /var/run/docker.sock:/var/run/docker.sock:ro jdel/inspec exec https://github.com/dev-sec/cis-docker-benchmark
[2017-05-03T15:41:40+00:00] WARN: URL target https://github.com/dev-sec/cis-docker-benchmark transformed to https://github.com/dev-sec/cis-docker-benchmark/archive/master.tar.gz. Consider using the git fetcher
/usr/local/bundle/gems/inspec-1.23.0/lib/resources/docker.rb:32:in `block (2 levels) in <class:DockerContainerFilter>': undefined method `downcase' for nil:NilClass (NoMethodError)
[...]

Below is the result from docker run -ti --rm --name inspec -v /var/run/docker.sock:/var/run/docker.sock:ro jdel/inspec shell with the troubleshooting commands you requested:
I have a different output than @kidbrax

Welcome to the interactive InSpec Shell
To find out how to use it, type: help

You are currently running on:

    OS platform:  alpine
    OS family:  alpine
    OS release: 3.4.6

inspec> docker
=> Docker Host
inspec> docker.containers
=> #<Inspec::Resources::DockerContainerFilter:0x005648f99aa298 @containers=[{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]>
inspec> docker.containers.running?
NoMethodError: undefined method `downcase' for nil:NilClass
from /usr/local/bundle/gems/inspec-1.23.0/lib/resources/docker.rb:32:in `block (2 levels) in <class:DockerContainerFilter>'
inspec> docker.containers.running?.ids?
NoMethodError: undefined method `downcase' for nil:NilClass
from /usr/local/bundle/gems/inspec-1.23.0/lib/resources/docker.rb:32:in `block (2 levels) in <class:DockerContainerFilter>'

If I run docker run -ti --rm --name inspec -v /var/run/docker.sock:/var/run/docker.sock:ro --entrypoint /bin/sh jdel/inspec I can then do a docker ps and see my containers running (4 of them).

To me this looks like a bug in docker.containers.running?

I have tried inspec 1.21, 1.22, and 1.23 with no success.

from cis-docker-benchmark.

chris-rock avatar chris-rock commented on May 17, 2024

@jdel Thank you, I agree that this looks like a bug in docker.containers.running? Can you please open an issue in https://github.com/chef/inspec/issues ?

from cis-docker-benchmark.

kidbrax avatar kidbrax commented on May 17, 2024

I have submitted an issue to inspec, inspec/inspec#1788

from cis-docker-benchmark.

chris-rock avatar chris-rock commented on May 17, 2024

Based on the inspec implementation, our baseline works only with Docker 1.13+

from cis-docker-benchmark.

chris-rock avatar chris-rock commented on May 17, 2024

I opened PR #35 to document the required docker version in our Readme. Since InSpec is keeping track of that, we can lower the required version if InSpec supports more. I am going to close this issue now. Please reopen if it required

from cis-docker-benchmark.

Related Issues (20)

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.