Using Docker with Terraform
Terraform can also be used to manipulate Docker. The classical usage is against an already running Docker server on the network, but it will work exactly the same locally with your own Docker installation. Using Terraform for controlling Docker, we'll be able to dynamically trigger Docker image updates, execute containers with every imaginable option, manipulate Docker networks, and use Docker volumes.
Here, we'll deploy an isolated blog container (Ghost) that will be publicly served by the nginx-proxy
container over HTTP. This very useful nginx-proxy
container is proposed by Jason Wilder from InfluxDB on his GitHub: https://github.com/jwilder/nginx-proxy.
Getting ready
To step through this recipe, you will need the following:
A working Terraform installation.
A working Docker installation (native Docker for Mac, Docker Engine on Linux, a remote server running Docker on TCP, and so on). Docker 1.12 is used for this recipe.
An Internet connection.
How to do it…
Before...