Docker: Difference between revisions

m
Line 88:
 
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 currently has four restart policies[https://blog.codeship.com/ensuring-containers-are-always-running-with-dockers-restart-policy/]:
Line 98:
;Multiple Instances
Create copies of root directory for different servers:
cp -r ~/docker-/nginx/ ~/docker-/nginx8080/
cp -r ~/docker-/nginx/ ~/docker-/nginx8081/
cp -r ~/docker-/nginx/ ~/docker-/nginx8082/
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 nginx8080nginx8081 -p 80808081:80 -d -v ~/docker-nginx8080/nginx8081/html:/usr/share/nginx/html --restart unless-stopped nginx
docker run --name nginx8081nginx8082 -p 80818082:80 -d -v ~/docker-nginx8081/nginx8082/html:/usr/share/nginx/html --restart unless-stopped nginx
docker run --name nginx8082nginx8083 -p 80828083:80 -d -v ~/docker-nginx8082/nginx8083/html:/usr/share/nginx/html --restart unless-stopped nginx
docker run --name nginx8083nginx8084 -p 80838084:80 -d -v ~/docker-nginx8083/nginx8084/html:/usr/share/nginx/html --restart unless-stopped nginx
 
Nginx 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
http://<IP_of_Server>:80808084
 
= RancherOS =