Running an NGinX webserver inside a Docker container

This tutorial shows how to run a webserver with docker.

Firstly create a VM - the instructions here are based on our ubuntu-focal-20.04-nogui image.

SSH to your VM and install docker:

sudo apt-get update && sudo apt-get install docker.io

Start and enable docker

sudo systemctl enable docker && sudo systemctl start docker

Add current user to the docker group (Please do NOT run docker and containers as root)

sudo usermod -aG docker ${USER}

Or if you need to add a user that is not logged in

To apply new group you must logout and log back in

You can confirm changes have applied by running

Pull the docker image for the nginx webserver

Run the nginx docker container:

Check that the container is running

You should see the nginx container running

You should now be able to browse to your webserver at the http://<instance-ip>

If this doesnt work check the security group for your instance, enabling http traffic through.