Inspec docker_container resource


I have a project with a chef recipe that creates a docker container and included is an InSpec test to make sure that it is running.
The issue I’m having is that InSpec does not seem to recognize the docker_container test

My test is essentially this just with different attribute contents:

describe docker_container('an-echo-server') do
  it { should exist }
  it { should be_running }
  its('id') { should_not eq '' }
  its('image') { should eq 'busybox:latest' }
  its('repo') { should eq 'busybox' }
  its('tag') { should eq 'latest' }
  its('ports') { should eq [] }
  its('command') { should eq 'nc -ll -p 1234 -e /bin/cat' }

And this is my error

Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #verify action: [undefined method `docker_container' for #<#<Class:0x00000003556790>:0x00000003555ea8>] on default-ubuntu-1604
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

I copy-pasted InSpec’s example code and fitted it to my occasion. What am I missing? Is there a dependency to use docker tests or something like that?

I’ve updated to the latest chef dk and have inspec declared as my verify-er in .kitchen.yml file

Thanks in advance


Hi, @sjgeorge2!

My guess is that the version of InSpec you’re using is older than the version in which the docker_container resource was added. What is the output of inspec version?


Hello, Adam!
Sorry for such a late reply, was out for the holidays. Happy New Year and all that!
I checked my inspec version and its 1.45.13 and I see that is indeed out of date. I assumed that the latest chefdk would include the latest inspec version.

I’ll get it updated and see if that is the fix!


Latest version of inspec gem(1.49.2 ) has been released. may be you can give it a try now.