nginxã®ãã¹ããæ°è»½ã«ãã¼ã«ã«ç°å¢ã§ããæ¹æ³
nginxã®è¨å®ã¯é£ãã
ã¢ããªã±ã¼ã·ã§ã³ã®éçºãã¦ãã¨ã³ã¸ãã¢ã«ã¨ã£ã¦nginxã®è¨å®ããã£ã¨æ¸ãã®ã¯çµæ§é£ããã§ãããï¼èªåãå«ãã¦ï¼ããã試ããªãããããããªãã¨æãã®ã§ããããªã¨ãã«æ°è»½ã«è©¦ããããæ¹ãç´¹ä»ãDockerã使ãã®ã§ãDocker for Macã¯ãã¡ããã¤ã³ã¹ãã¼ã«ãã¦ããã¦ãã ãããã
é©å½ã«ãã£ã¬ã¯ããªä½ã
éã«ãã¹ã¯ãããã«nginxã¿ãããªãã£ã¬ã¯ããªä½ãã
mkdir ~/Desktop/nginx
å ¬å¼ã®nginxã®confããã¯ã
# nginx.confããã¯ã $ docker run -it nginx:alpine cat /etc/nginx/nginx.conf > ~/Desktop/nginx/nginx.conf # default.confããã¯ã $ docker run -it nginx:alpine cat /etc/nginx/conf.d/default.conf > ~/Desktop/nginx/default.conf
Dockerfileãæ¸ã
FROM nginx:alpine COPY nginx.conf /etc/nginx/nginx.conf COPY default.conf /etc/nginx/conf.d/default.conf CMD ["nginx", "-g", "daemon off;"]
Makefileãæ¸ã
run: docker build -t nginx-test . docker run -it -p 8080:80 nginx-test
ãããããã¡ã¤ã«æ§æã«ãªã
â ~ tree Desktop/nginx Desktop/nginx âââ Dockerfile âââ Makefile âââ default.conf âââ nginx.conf
ãã¹ãéå§
make run
ããã ã
â nginx pwd /Users/mpon/Desktop/nginx â nginx make run docker build -t nginx-test . Sending build context to Docker daemon 6.656kB Step 1/4 : FROM nginx:alpine ---> bb00c21b4edf Step 2/4 : COPY nginx.conf /etc/nginx/nginx.conf ---> Using cache ---> 4c5cd27c66a9 Step 3/4 : COPY default.conf /etc/nginx/conf.d/default.conf ---> Using cache ---> db9944326ade Step 4/4 : CMD ["nginx", "-g", "daemon off;"] ---> Using cache ---> e92d1c2f667f Successfully built e92d1c2f667f Successfully tagged nginx-test:latest docker run -it -p 8080:80 nginx-test
http://localhost:8080 ã«ã¢ã¯ã»ã¹ãã¦ãWelcome to nginx!
ãã¨ã¯ã好ãã«
default.confãããã£ã¦ãåã³make run
ããã°OK