In first demo we had installed and run nginx on Ubuntu 16.04 locally.
In the demo after that, we installed Docker.
You might find a pattern here and you you might have been
able to figure out, that in this demo we are going to run
nginx as a Docker container.
Unlike hello-world container, we will do this in a bit more elaborate way.
Let's start with pulling an image called nginx:latest
from Docker hub's nginx repository,
by running the command 'docker image pull nginx:latest'.
This will download or pull an image called nginx with latest tag
which can later be run as a container.
Let's see if we have got our image, run 'docker images' command
to show the list of images.
And here we go, we have two images,
first is hello-world, which we used in the last demo and second
is nginx, which we are using in this demo.
Both of them have TAG called latest and they have different sizes.
Now let's run this image as a container using 'docker container run' command
followed by -itd flag and name our container
web-server-nginx. With -p command,
we are mapping the Port 8080 of our local machine to container's port 80.
And finally we are mentioning the image name nginx:latest
which we have just pulled recently.
What we got is a container id of the nginx container.
I know all of this terminology sounds pretty new and pretty abrupt.
But don't worry, in this demo, our only purpose
is to run nginx successfully.
We will go through all of these terms in sufficient details
when the time arrives. Let's verify that our container is
running by running the command 'docker ps -a' and as you can see,
web-server nginx container is running which is built upon
image called nginx:latest.
Finally, let's see the output of this container by going
to the web browser and opening our localhost port 8080
and it works successfully.