geeknam / tocker

tocker: TDD for Dockerfile
12 stars 1 forks source link
python tdd testinfra

tocker: TDD for writing Dockerfile

Build Status

About

tocker is a plugin for testinfra that allows developers to test docker images

asciicast

Getting Started

pip install tocker

Set your environment variables to connect to docker engine:

export DOCKER_HOST=unix:///var/run/docker.sock

If docker engine runs a different host, set the following:

export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://ip:port
export DOCKER_CERT_PATH=/path/to/certs

If you're using docker-machine, you can simply run:

eval $(docker-machine env myenv)

Workflow

  1. Create a Dockerfile
  2. Create a test.py in the same directory
  3. Add IMAGE_TAG to test.py. E.g: mycorp/nginx:1.9.12
  4. Write your tests (find out more about how to use different modules from testinfra docs)
  5. Run testinfra test.py (-s -v for verbose mode)
  6. Watch your tests fail
  7. Edit your Dockerfile until the tests pass
  8. When you're happy docker push the image

How does it work?

Contribute

If you're looking to add a new module, please contribute to testinfra.

If it's more specific to Docker, you can add additional fixtures under tocker/fixtures.py. Pull requests are welcome.