Docker Compose and TestContainers

Learn how to use TestContainers-scala to run Docker containers from a Docker Compose file.

In this lesson, we’ll use TestContainers-scala with a Docker Compose file describing the infrastructural dependencies of our application. The only dependency we’ll need is a Docker container running LocalStack. While a Docker Compose file isn’t necessary, it’s a good way to understand how the approach works.

The Docker Compose file

The first thing we have to do when we want to use TestContainers-scala with a Docker Compose file is write a file listing all our external services. In the following examples, we’ll be using only LocalStack, so our Docker Compose file will only have one service.

Get hands-on with 1200+ tech skills courses.