Docker: Difference between revisions

(→‎NGINX: added)
Line 59:
 
= NGINX =
Source: [https://www.digitalocean.com/community/tutorials/how-to-run-nginx-in-a-docker-container-on-ubuntu-14-04 digitalocean.com]
docker search nginx
 
Create nginx root directory:
 
mkdir -p ~/docker-nginx/html
cd ~/docker-nginx/html
nano index.html
 
Paste below contents into this file
<pre>
<html>
Line 79 ⟶ 83:
</html>
</pre>
 
Install nginx image for docker
docker search nginx
 
Run nginx docker image
docker run --name nginx -p 80:80 -d -v ~/docker-nginx/html:/usr/share/nginx/html nginx
 
== Multiple Instances ==
Create copies of root directory for different servers:
cp -r ~/docker-nginx/ ~/docker-nginx8080/
cp -r ~/docker-nginx/ ~/docker-nginx8081/
Line 87 ⟶ 97:
cp -r ~/docker-nginx/ ~/docker-nginx8083/
 
Edit the Index.html file to reflect different content by editing the html code.
 
Start different instances of nginx to start with different ports & root directories:
docker run --name nginx8080 -p 8080:80 -d -v ~/docker-nginx8080/html:/usr/share/nginx/html nginx
docker run --name nginx8081 -p 8081:80 -d -v ~/docker-nginx8081/html:/usr/share/nginx/html nginx
docker run --name nginx8082 -p 8082:80 -d -v ~/docker-nginx8082/html:/usr/share/nginx/html nginx
docker run --name nginx8083 -p 8083:80 -d -v ~/docker-nginx8083/html:/usr/share/nginx/html nginx
 
Docker instances should now be available using below links:
http://<IP_of_Server>:8080
http://<IP_of_Server>:8081
http://<IP_of_Server>:8082
http://<IP_of_Server>:8083
 
<br />