Terraform

Starting at the top, we're going to use Terraform to create a small Docker deployment locally. This is the easiest to show as we have all of the tools we need on our VM, and it doesn't mean I have to tell you to go out and start a free trial on some cloud provider.

Start by creating a directory for us to work in:

$ mkdir example-terraform$ cd example-terraform

Next, shove the following configuration into a main.tf file:

$ cat <<HERE > main.tfprovider "docker" {  host = "unix:///var/run/docker.sock"}resource "docker_image" "example-image" {  name = "nginx"}resource "docker_container" "example-container" {  name = "nginx-example"  image = "\${docker_image.example-image.latest}"}HERE

Then, initialize Terraform:

$ sudo /usr/local/bin/terraform ...

Get Linux Administration Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.