Chef Test Kitchen verify file exists inside Docker container

1.1k Views Asked by At

I try to run simple test using Chef test kitchen:

  describe file('/opt/test_file.txt') do
    it { should exist }
  end

I can easy run this test on my kitchen machine (virtualBox/centos-7.2) using kitchen verify.

How can I run this test inside a Docker container installed in my kitchen machine?

1

There are 1 best solutions below

1
On BEST ANSWER

In general would try to handle docker container spec tests as part of the image building process, however, I guess you could run something like this:

describe bash('docker exec -it YOUR_CONTAINER test -f /opt/test_file.txt') do
  its('exit_status') { should eq 0 }
end