serverspec/serverspec — pull request #482 by mizzy (2014-10-12 05:00:12+00:00)
Title: Another implementaion of Docker resource type (Ref #480)

### Images

Check if a specific image been pulled to the host.

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

Check the attributes hash returned by `docker inspect`.

```ruby
describe docker_image('busybox:latest') do
its(:inspection) { should_not include 'Architecture' => 'i386' }
end
```

You can alaso specify hash key like this.

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

You can also specify nested hash key like this.

```ruby
describe docker_image('busybox:latest') do
its(['Config.Cmd']) { should include '/bin/sh' }
end
```

### Containers

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 exist }
it { should be_running }
end
```

Check the attributes hash returned by `docker inspect`.

```ruby
describe docker_container('c1') do
its(:inspection) { should include 'Path' => '/bin/sh' }
end
```

You can alaso specify hash key like this.

```ruby
describe docker_container('c1') do
its(['Path']) { should eq '/bin/sh' }
end
```

You can also specify nested hash key like this.

```ruby
describe docker_container('c1') do
its(['HostConfig.NetworkMode']) { should eq 'bridge' }
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
```