We don't need to spend a lot of time talking about Docker at the moment.
We'll spend more time in the next module looking at Docker.
But one of the primary things that we must have with Docker is our image.
And this image then can define our containers,
and our containers are our running instances.
So we can define a resource block within our main.tf.
Here we're saying then it's a docker_image,
and we're basing that docker_image based around nginx.
We can specify the name.
This would be the name in the repository where we download Docker
images from from our main Docker repository.
Keep_locally means that we don't need to keep the
image once we've finished with it,
so we can delete it once we've finished with it.
And we close off our brace bracket.
Remember, these are JSON formatted files.
As we continue,
the next part of our main.tf file is going to be the docker_container.
So we can see here, we're defining our docker_container resource.
Docker relating back to whatever we had called our provider.
We're basing it then on our nginx image.
We're giving a name to the container of webserver.
So we can access it,
we're mapping port 80 on the container to port 8000 on our host.
And we're also then, so we've got web pages,
we can go through and have the container webserver,
so usr/share/nginx/html, the document root for our nginx server,
mapped through to our host system.
In our terraform directory,
we can create a subdirectory called web with the web
resources that we need for our web page.
Close off our word volumes and close off then our resource.
Now, once we've got this, we can then go through and apply the terraform file,
and the terraform file then is going to start up our container.
And we're going to be able to access our website on port 8000 of our localhost. Let's go out to our command line and see this in action.