我已经使用ng build
现在我cd
到dist/iDot
文件夹并运行
docker run -d -p 8080:80 -v $(pwd):/usr/share/nginx/html nginx:alpine
但是当我访问URL时,它显示nginx 403 Forbidden
错误。
我有chmod 777
个dist文件夹和文件,似乎没有任何影响。
Dist文件夹
garg10may@GCES15511:~/iDot/frontend/dist$ ls
iDot
garg10may@GCES15511:~/iDot/frontend/dist$ ls -ltrh iDot/
total 21M
-rwxrwxrwx 1 garg10may garg10may 49K May 3 18:02 main.js
-rwxrwxrwx 1 garg10may garg10may 284K May 3 18:02 es2015-polyfills.js
-rwxrwxrwx 1 garg10may garg10may 767K May 3 18:02 styles.js
-rwxrwxrwx 1 garg10may garg10may 6.1K May 3 18:02 runtime.js
-rwxrwxrwx 1 garg10may garg10may 236K May 3 18:02 polyfills.js
-rwxrwxrwx 1 garg10may garg10may 207K May 3 18:02 es2015-polyfills.js.map
-rwxrwxrwx 1 garg10may garg10may 8.9M May 3 18:02 vendor.js
-rwxrwxrwx 1 garg10may garg10may 28K May 3 18:02 main.js.map
-rwxrwxrwx 1 garg10may garg10may 6.1K May 3 18:02 runtime.js.map
-rwxrwxrwx 1 garg10may garg10may 235K May 3 18:02 polyfills.js.map
-rwxrwxrwx 1 garg10may garg10may 820K May 3 18:02 styles.js.map
-rwxrwxrwx 1 garg10may garg10may 9.4M May 3 18:02 vendor.js.map
-rwxrwxrwx 1 garg10may garg10may 829 May 3 18:02 index.html
-rwxrwxrwx 1 garg10may garg10may 5.4K May 3 18:02 favicon.ico
容器运行正常
garg10may@GCES15511:~/iDot/frontend$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fcd8af3018e6 nginx:alpine "nginx -g 'daemon of…" 10 minutes ago Up 10 minutes 0.0.0.0:8080->80/tcp wonderful_shockley
5e1e49e7cc24 idot "java -Djava.securit…" 6 hours ago Up 6 hours 0.0.0.0:8081->8081/tcp idot
69a43bc460e1 mysql:5.7 "docker-entrypoint.s…" 6 hours ago Up 6 hours 3306/tcp, 33060/tcp idb
码头工人日志{容器}
2019/05/03 12:54:34 [error] 7#7: *1 directory index of "/usr/share/nginx/html/" is forbidden, client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:8080"
172.17.0.1 - - [03/May/2019:12:54:34 +0000] "GET / HTTP/1.1" 403 556 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" "-"
尝试1:
garg10may@GCES15511:~/iDot/frontend/dist/iDot$ ls
es2015-polyfills.js favicon.ico main.js polyfills.js runtime.js styles.js vendor.js
es2015-polyfills.js.map index.html main.js.map polyfills.js.map runtime.js.map styles.js.map vendor.js.map
garg10may@GCES15511:~/iDot/frontend/dist/iDot$ cd ..
garg10may@GCES15511:~/iDot/frontend/dist$ docker run -d -p 8080:80 -v $(pwd)/iDot:/usr/share/nginx/html nginx:alpine
21910db703790152bf622ce01b2c814a224f1054e103e1d6b62c4b71fd47d542
garg10may@GCES15511:~/iDot/frontend/dist$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
21910db70379 nginx:alpine "nginx -g 'daemon of…" 3 seconds ago Up 1 second 0.0.0.0:8080->80/tcp ecstatic_germain
5e1e49e7cc24 idot "java -Djava.securit…" 7 hours ago Up 7 hours 0.0.0.0:8081->8081/tcp idot
69a43bc460e1 mysql:5.7 "docker-entrypoint.s…" 7 hours ago Up 7 hours 3306/tcp, 33060/tcp idb
garg10may@GCES15511:~/iDot/frontend/dist$ docker exec -it ecstatic_germain ls -l /usr/share/nginx/html/
total 0
drwxr-xr-x 2 root root 40 May 3 12:47 iDot
garg10may@GCES15511:~/iDot/frontend/dist$ docker exec -it ecstatic_germain ls -l /usr/share/nginx/html/iDot
total 0
garg10may@GCES15511:~/iDot/frontend/dist$
答案 0 :(得分:0)
我认为dist文件夹中将存在另一个具有应用程序名称的文件夹,您需要在将其映射到nginx图像的卷上提供该文件夹。 cd进入您的应用程序名称文件夹并运行相同的命令,
答案 1 :(得分:0)
改为挂载iDot目录-
$ cd ~/iDot/frontend/dist
$ docker run -d -p 8080:80 -v $(pwd)/iDot:/usr/share/nginx/html nginx:alpine
您可能会收到403,因为nginx无法在文档根目录获得可读/可执行的index.html
文件。
有关更多信息,请尝试在容器中进行docker exec
-
$ docker exec -it 88c73dc32cad ls -l /usr/share/nginx/html/