Docker: Difference between revisions

Content added Content deleted
Line 88: Line 88:


Run nginx docker image with auto Restart on reboot option
Run nginx docker image with auto Restart on reboot option
docker run --name nginx -p 80:80 -d -v ~/docker-nginx/html:/usr/share/nginx/html --restart unless-stopped nginx
docker run --name nginx -p 80:80 -d -v ~/docker/nginx/html:/usr/share/nginx/html --restart unless-stopped nginx


Docker currently has four restart policies[https://blog.codeship.com/ensuring-containers-are-always-running-with-dockers-restart-policy/]:
Docker currently has four restart policies[https://blog.codeship.com/ensuring-containers-are-always-running-with-dockers-restart-policy/]:
Line 98: Line 98:
;Multiple Instances
;Multiple Instances
Create copies of root directory for different servers:
Create copies of root directory for different servers:
cp -r ~/docker-nginx/ ~/docker-nginx8080/
cp -r ~/docker/nginx/ ~/docker/nginx8080/
cp -r ~/docker-nginx/ ~/docker-nginx8081/
cp -r ~/docker/nginx/ ~/docker/nginx8081/
cp -r ~/docker-nginx/ ~/docker-nginx8082/
cp -r ~/docker/nginx/ ~/docker/nginx8082/
cp -r ~/docker-nginx/ ~/docker-nginx8083/
cp -r ~/docker/nginx/ ~/docker/nginx8083/


Edit the Index.html file to reflect different content by editing the html code.
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:
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 --restart unless-stopped 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 --restart unless-stopped 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 --restart unless-stopped nginx
docker run --name nginx8083 -p 8083:80 -d -v ~/docker-nginx8083/html:/usr/share/nginx/html nginx
docker run --name nginx8084 -p 8084:80 -d -v ~/docker/nginx8084/html:/usr/share/nginx/html --restart unless-stopped nginx


Nginx instances should now be available using below links:
Nginx instances should now be available using below links:
http://<IP_of_Server>:8080
http://<IP_of_Server>:8081
http://<IP_of_Server>:8081
http://<IP_of_Server>:8082
http://<IP_of_Server>:8082
http://<IP_of_Server>:8083
http://<IP_of_Server>:8083
http://<IP_of_Server>:8084


= RancherOS =
= RancherOS =