Terraform Docker Example
Reusable Terraform modules for managing Docker containers and AWS ECS Fargate, with progressive examples and local testing with LocalStack.
evergreen#terraform#docker#ecs#localstack#infrastructure-as-code
What it is
Reusable Terraform modules for managing Docker containers locally and on AWS ECS Fargate. Includes four progressive examples ranging from basic containers to ECS testing with LocalStack.
Available as source code.
Examples
- Basic Docker — container module, networking, and port mapping
- FastAPI + React — full-stack application with custom Dockerfiles
- Docker Compose — the same app for approach comparison
- ECS with LocalStack — AWS ECS testing at zero cost
Included modules
- docker-container — local Docker container management with dynamic port mapping, environment variables, and network configuration
- ecs-fargate — ECS clusters, task definitions, services, CloudWatch Logs, and Container Insights
Why it matters
Terraform and Docker Compose solve different problems. This project demonstrates when to use each with practical examples, and shows how to test AWS infrastructure locally with LocalStack before spending on the cloud.
References
- GitHub Repository — jonmatum, 2025. Source code, modules, and documentation.
- Terraform Docker Provider — kreuzwerker, 2024. Provider documentation.
- LocalStack — LocalStack, 2024. Local AWS service emulator.