我也没怎么用过docker desktop,一直以为是配置的问题,现在发现是路径错误。
解决办法:
1. 在本地 Vue 项目里运行:npm run build
打包得到一个 dist 文件夹
2. 打开 Docker Desktop → 运行Nginx镜像 → 打开你的 Nginx 容器 → 然后第五列有个 Files
3. 查看路径usr/share/nginx/html 然后把 dist 直接拖到 html 文件夹里
因为这里有点问题,只能选择文件夹,于是需要修改下路径
5./etc/nginx/conf.d/default.conf
修改/usr/share/nginx/html指向/usr/share/nginx/html/dist
6. 访问:http://localhost