Friday, June 2, 2017

Notes for Experiments running Nginx in a Docker Container on Linode

Goal:

Get a Nginx Instance Running on Linode using a DNS alias:



(1) Get Nginx running.

Three ways to get Nginx on Docker:

Build it in with the Digital Ocean Tutorial (running Nginx on an Ubuntu Image):


https://www.digitalocean.com/community/tutorials/docker-explained-how-to-containerize-and-use-nginx-as-a-proxy


( & any Linode specific configuration??)

Pull a Docker image for Nginx from Docker Hub:
https://hub.docker.com/_/nginx/

Get the default Nginx page running:
sudo docker pull nginx
sudo docker run --name another-nginx -d -p 8040:80 nginx

Get a customized Nginx page running:sudo docker pull nginx
(does not need to be repeated, and the command below can be run concurrently)

Create index.html in /home/brent/Documents/dockerexperiments/nginx

docker run --name the-third -v /home/brent/Documents/dockerexperiments/nginx:/usr/share/nginx/html:ro -d -p 8030:80 nginx

or try a docker-compose script:
https://serversforhackers.com/getting-started-with-docker

Once you have an image built (or if you want to go back to what you have):

create index.html in /home/brent/share/
docker run -v /home/brent/share/:/var/www:rw -p 80:80 -d nginx-example

(2) Point it to a subdomain.
http://freedns.afraid.org/

Result of pulling from docker hub, getting the default Nginx running, and pointing the Public IP to a subdomain:











To do this locally with a particular file:

create index.html in /home/brent/share/
docker run -v /home/brent/share/:/var/www:rw -p 80:80 -d nginx-example

(check this:

docker run --name the-third -v /home/brent/Documents/dockerexperiments/nginx:/usr/share/nginx/html:ro -d -p 8030:80 nginx

I think it is to run an image from a container)





No comments:

Post a Comment