serverspec/serverspec — pull request #480 by aschmidt75 (2014-10-10 08:12:42+00:00)
Title: Integrate docker resource type

# Serverspec2 resource types for docker images and containers

Purpose is to check whether a host contains images within its local
cache and whether named containers have been instantiated. Be able to
query arbirary settings from `docker inspect` output.

## Images

Check if a specific image been pulled to the host

```ruby
describe docker_image('busybox:latest') do
it { should be_present }
end
```

Query an image setting from `docker inspect`, i.e. ensure that
a given image is not 32bit:

```ruby
describe docker_image('busybox:latest') do
it { should_not have_setting('Architecture','i386') }
end
```

Same with `its(..)` syntax:

```ruby
describe docker_image('busybox:latest') do
its(:Architecture) { should eq 'amd64' }
end
```

## Volumes

Ensure that a container is present (listed in docker ps -a) and running,
identified by name, i.e. `docker run -tdi --name "c1" busybox`

```ruby
describe docker_container('c1') do
it { should be_present }
it { should be_running }
end
```

Query settings via `docker inspect`:

```ruby
describe docker_container('c1') do
its(:HostConfig_NetworkMode) { should eq 'bridge' }
its(:Path) { should eq '/bin/sh' }
end
```

A check for volumes being mounted, i.e. by
`docker run -tdi --name "c2" -v /data:/tmp busybox`:

```ruby
describe docker_container('c2') do
it { should have_volume('/tmp','/data') }
end
```