728x90
반응형
Run Nginx on Docker
1. Create Dockerfile
1 2 3 4 | FROM nginx COPY html /usr/share/nginx/html # html directory of content ADD nginx.conf /etc/nginx/nginx.conf # nignx config file CMD ["nginx", "-g", "daemon off;"] | cs |
2.Create nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | user nobody nogroup; worker_processes auto; # auto-detect number of logical CPU cores events { worker_connections 512; # set the max number of simultaneous connections (per worker process) } http { server { listen *:80; # Listen for incoming connections from any interface on port 80 server_name ""; # Don't worry if "Host" HTTP Header is empty or not set root /usr/share/nginx/html; # serve static files from here } } | cs |
3. Create /html/index.html for test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | html> <head> <title>Sample "Hello, World" Application</title> </head> <body bgcolor=white> <table border="0" cellpadding="10"> <tr> <td> <h1>Sample "Hello, World" Application</h1> </td> </tr> </table> <p>This is the home page for the HelloWorld Web application. </p> </body> </html> | cs |
3. docker build
1 | docker build -t docker-nginx . | cs |
4. Check docker image
1 2 3 | $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker-nginx latest c86e2b339c31 About an hour ago 182.5 MB | cs |
5. docker run
1 | docker run --name docker-nginx -d -p 80:80 docker-nginx | cs |
6. Connect [host_ip or localhost]:8080 and Check
728x90
반응형
'Programming > Docker' 카테고리의 다른 글
[Docker] linux docker 특정 버전 install (18.06) (0) | 2022.01.12 |
---|---|
docker file copy from container to host (0) | 2017.04.03 |
socket.io load balancing with HAProxy on Docker (0) | 2017.03.28 |
HAProxy with Docker (0) | 2017.03.24 |
docker upgrade (error : The engine version is lesser than the minimum required by compose) (0) | 2016.07.18 |
댓글0