# docker_Nginx筆記 - 建立一個目錄叫data並進去 ``` mkdir data cd data ``` - 建立4樣東西 ![](https://i.imgur.com/VkcqBmG.png) ### Dockerfile ``` FROM nginx COPY index.html /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf COPY /member_test /member_test/ RUN apt-get update RUN apt-get install -y vim python python-pip curl RUN pip install -r /member_test/requirements.txt RUN cd /tmp RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh RUN sh -c '/bin/echo -e "\nyes\n\nyes" | sh Miniconda3-latest-Linux-x86_64.sh' ``` ### Docker-compose.yml 組合了docker build 與 docker run 的yml檔 ``` version: "3.7" services: nginx: build: context: . dockerfile: Dockerfile args: tag list: kenson_nginx restart: always image: kenson_nginx ports: - "7777:80" container_name: kenson ``` ### index.html ``` <h1> Nginx index </h1> ``` ### nginx.conf ``` server{ listen 80 default_server; listen [::]:80 default_server; server_name lou.com; root /usr/share/nginx/html; index index.html; charset utf-8; access_log /var/log/nginx/access_log; error_log /var/log/nginx/error_log; } ``` - 在當前目錄下執行docker-compose ``` docker-compose up -d ``` - 服務完成起來以後就可以看到 ![](https://i.imgur.com/qnGtyRP.png) - docker images (已build kenson_nginx) ![](https://i.imgur.com/nGPlVSC.png) - docker run nginx( name:kenson) ![](https://i.imgur.com/CxK9z5D.png) - 開啟網頁 url:7777 ![](https://i.imgur.com/6CW6r3j.png)