Docker serverspec for container testing
1.7K
Docker container to run serverspec via Docker-in-Docker.
Docker-ception in action:
$ docker pull nanliu/serverspec:alpine
$ docker run -v /var/run/docker.sock:/var/run/docker.sock \
-it nanliu/serverspec:alpine /bin/sh
You should see all running containers in the serverspec container and all your docker images
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
405492d2c3fa nanliu/serverspec:alpine "docker-entrypoint.sh" 8 seconds ago Up 7 seconds vibrant_wright
# docker images
...
# exit
Run a serverspec test:
$ git clone https://github.com/nanliu/docker-serverspec.git
$ cd docker-serverspec
$ docker run -v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)":/serverspec \
-it nanliu/serverspec:alpine /bin/sh -c "cd /serverspec && rspec snap_spec.rb"
Run a serverspec test with pry rescue:
$ cd docker-serverspec
$ docker run -v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)":/serverspec \
-it nanliu/serverspec:alpine /bin/sh -c "cd /serverspec && rescue rspec snap_spec.rb"
snap/Dockerfile to a new maintainer (your own name)MAINTAINER your name <[email protected]>
snap_spec.rb to match this change.snap/Dockerfile to match the following:COPY snapteld.conf /etc/snapteld.conf
snap_spec.rb to match this change.this will cause the symlink tests to fail
snap/init_snap to match this change.[ -f /etc/snap/snapd.conf ] || ln -s /etc/snapteld.conf /etc/snap/snapd.conf
hint:
describe docker_run('intelsdi/snap:alpine')
#test
end
hint:
$ vim mysql_spec.rb
describe docker_build('/serverspec/mysql/.')
describe docker_run(described_image) do
#test
end
end
$ cd docker-serverspec
$ docker run -v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)":/serverspec \
-it nanliu/serverspec:alpine /bin/sh -c "cd /serverspec && rspec mysql_spec.rb"
Content type
Image
Digest
Size
81.9 MB
Last updated
about 9 years ago
docker pull nanliu/serverspec