- 在服務器上創建一個存放該文件的文件夾,將生成的文件上傳到這個文件夾下。
- 上傳的同級目錄中創建Dockerfile以及nginx.conf兩個文件。
-
# 設置基礎鏡像 FROM nginx # 定義作者 MAINTAINER L # 將dist文件中的內容復制到 /usr/share/nginx/html/ 這個目錄下面 COPY dist/ /usr/share/nginx/html/ COPY nginx.conf /etc/nginx/nginx.conf RUN echo 'echo init ok!!'
worker_processes auto; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 20m; server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
- 創建鏡像:docker build -t vuejs:1.0 .
- 查看鏡像:docker images
-
構建容器:docker run -d --name vue -p 80:80 vuejs:1.0
-
查看容器啟動狀態:docker ps
-
頁面訪問:http://服務器的ip/