Testing Docker containers with BATS
BATS (Bash Automated Testing System) allows you to have quick and easy tests in a very natural language, without the need of a lot of dependencies. BATS can also grow in complexity as per your requirement. In this section, we'll use Docker with Docker Compose to handle the build and a Makefile to tie the dependencies between the build process and the BATS testing process; this will make it easier to later integrate this process into a CI system.
Getting ready
To step through this recipe, you will need:
- A working Docker installation
- A BATS installation (it's available for all major Linux distributions and Mac OS)
Note
BATS Version 0.4.0 is used in this chapter.
How to do it…
Let's start with this simple Dockerfile that will install Apache and run it after clearing the cache:
FROM debian:stable-slim LABEL name="apache" LABEL maintainer="John Doe <[email protected]>" LABEL version=1.0 RUN apt-get update -y \ &&...