- Create a folder name it as "docker-nginx"
- Create a file with name “index.html” under “docker-nginx” folder
- Add <p></p> tag with sample text in index.html file
- Pull nginx:alpine docker image into host machine
- Write docker run command by setting following options
- enable detached mode
- set container name as "helloworldnginx"
- set container working directory i.e. /usr/share/nginx/html
- do bind mount of “docker-nginx” folder from host machine to container /usr/share/nginx/html folder
- map host port number to 8200
Command:
> docker run -d -p 8200:80
--name helloworldnginx
--mount type=bind,source=/c/Users/rama/docker-nginx,target=/usr/share/nginx/html
nginx:alpine (or)
> docker run -d -p 8200:80
--name helloworldnginx
--mount type=bind,source=$(pwd),target=/usr/share/nginx/html
nginx:alpine
(i.e. pwd should be docker-nginx folder)
- -d --> used to run container in detached/background mode
- -p 8200:80 --> map host port number 8200 to container port 80 ( i.e. nginx expose port 80 by default )
- /usr/share/nginx/html --> nginx default site enabled folder
Note : https://github.com/nginxinc/NGINX-Demos is a official nginx git repo and has awesome demos
Happy Coding :)
No comments:
Post a Comment