我正在嘗試使用 dockerfile 在 docker 中托管一個靜態站點
dockerfile
FROM nginx:latest
COPY . /usr/share/nginx/html
碼頭工人命令
docker build -t newwebsite .
docker run --name website -d -p 8080:80 newwebsite
但是運行 localhost:8080 時仍然顯示 nginx 默認頁面
我該如何除錯這個?
uj5u.com熱心網友回復:
運行命令的目錄中是否有任何內容docker build?
COPY . /user/share/nginx/html
這表明內容正在從當前目錄復制到 Docker 映像中的路徑。
另一種方法是進入正在運行的容器并對其進行除錯。
(host) $ docker exec -it website /bin/bash
root@5bae70747b2c:/#
root@5bae70747b2c:/# ls -ltra /usr/share/nginx/html
total 20
-rw-r--r-- 1 root root 497 Jan 25 15:03 50x.html
drwxr-xr-x 1 root root 4096 May 28 05:40 ..
-rw-r--r-- 1 root root 48 Jun 7 03:50 Dockerfile
-rw-r--r-- 1 root root 135 Jun 7 03:51 index.html
drwxr-xr-x 1 root root 4096 Jun 7 03:51 .
上面是一個用 Nginx 服務 index.html 的例子,你可以檢查一下里面是否有這樣的內容/usr/share/nginx/html。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/490082.html
標籤:码头工人 nginx dockerfile
