ABOUT ME

하루하루를 의미있게!

Today
Yesterday
Total
  • Docker: alpine + nginx Image 만들기
    공부합시다!/Container 2023. 9. 11. 11:34
    728x90

    alpine 이용하여  간단하게 nginx image를 Dockerifle로 만들어 보겠습니다.

     

    1. nginx.conf 파일 작성

    user  nginx;
    worker_processes  auto;
    
    error_log  /var/log/nginx/error.log notice;
    pid        /var/run/nginx/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        sendfile on;
        access_log /var/log/nginx/access.log;
        keepalive_timeout 3000;
        server {
            listen 80;
            root /var/lib/nginx/html;
            index   index.html;
            server_name     locahost;
            client_max_body_size 32m;
            error_page 500 502 503 504 /50x.html;
            location = /50x.html {
            }
        }
    }

     

    2. index.html 파일 작성

     

    3. Dockerfile 작성

    # step1: base image download
    FROM    alpine
    
    # step2: /etc/apk/repositories fix
    RUN	sed -i 's/https/http/g' /etc/apk/repositories
    
    # step3: nginx packgae add
    RUN     apk add nginx
    
    # step4: nginx.conf add
    COPY    nginx.conf      /etc/nginx/nginx.conf
    COPY    index.html      /var/lib/nginx/html/index.html
    #ADD    https://ko.wordpress.org/wordpress-5.7.8-ko_KR.tar.gz   ./  #ADD Test
    # step5: port 80/tcp
    EXPOSE  80
    
    # step6: excute
    #ENTRYPOINT     ["nginx"]
    #CMD            ["-g", "daemon off;"]
    CMD     nginx -g 'daemon off;'

     

    4. 파일 확인

     

    5. docker build 및 build image 확인, 실행

     

     

    728x90

    '공부합시다! > Container' 카테고리의 다른 글

    alpine linux in docker  (1) 2024.05.30
    Dockerfile - CentOS7 + HTTPD  (0) 2023.05.19
    Podman: Container를 System Service로 관리  (0) 2023.01.25
    Docker: cp & tar 다중 파일 복사  (0) 2023.01.05
    PODMAN: Network  (0) 2022.12.20
Designed by Tistory.