WINDOWS 10 HOME DOCKER NGINX 403 FORBIDDEN


在docker用nginx網路伺服器跑靜態網頁會出現403 Forbidden 錯誤頁面。

This image has an empty alt attribute; its file name is docker403Nginx-1024x576.png

原因除了廣為人知的permission(權限)問題。也有可能是路徑的問題 (路徑不存在)。解決方法如下:

步驟一:

先下載linux image:

docker pull alpine

This image has an empty alt attribute; its file name is alpineLinux.png

Alpine Linux是一套極小型的作業系統

步驟二:

切換到linux環境裡

docker run -it alpine sh

步驟三:

建立路徑:

mkdir usr/share/nginx/html

步驟四:

離開linux環境:

alpine exit

步驟五:

再執行docker command

docker run –rm -it -p 5012:80 -v directory:/usr/share/nginx/html -d nginx

執行結果如下:

This image has an empty alt attribute; its file name is solitaire.png

該靜態頁面可從pluralsight(Getting Started with Docker on Windows)下載