Docker: Difference between revisions

→‎Nginx: custom
(→‎NGINX: port)
(→‎Nginx: custom)
Line 106:
 
Start different instances of nginx to start with different ports & root directories:
docker run --name nginx8081 -p 8081:80 -d -v ~/docker/nginx8081/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 --restart unless-stopped nginx
docker run --name nginx8083 -p 8083:80 -d -v ~/docker/nginx8083/html:/usr/share/nginx/html --restart unless-stopped 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:
Line 117:
http://<IP_of_Server>:8084
 
;Changing port or running custom config:
Copy the nginx file from docker file system to local filesystem:
sudo docker cp nginx:/etc/nginx/conf.d/default.conf /home/aman/docker/default.conf
 
Edit the config file to change the listening port to 8000:
nano default.conf
 
Now start the docker container with the new port:
docker run --name docker-nginx -p 8081:80818000 -v ~/docker/nginx8081/html:/usr/share/nginx/html -v ~/docker/default.conf:/etc/nginx/conf.d/default.conf -d nginx
 
;Running multiple instances with custom ports & autostart on bootup:
<pre style="width: 97%; overflow-x: scroll;">
docker run --name nginx8081 -p 8081:8000 -d -v ~/docker/nginx8081/html:/usr/share/nginx/html -v ~/docker/default.conf:/etc/nginx/conf.d/default.conf --restart unless-stopped nginx
docker run --name nginx8082 -p 8082:8000 -d -v ~/docker/nginx8082/html:/usr/share/nginx/html -v ~/docker/default.conf:/etc/nginx/conf.d/default.conf --restart unless-stopped nginx
docker run --name nginx8083 -p 8083:8000 -d -v ~/docker/nginx8083/html:/usr/share/nginx/html -v ~/docker/default.conf:/etc/nginx/conf.d/default.conf --restart unless-stopped nginx
docker run --name nginx8084 -p 8084:8000 -d -v ~/docker/nginx8084/html:/usr/share/nginx/html -v ~/docker/default.conf:/etc/nginx/conf.d/default.conf --restart unless-stopped nginx</pre>
 
= RancherOS =