问题描述
我试图运行一个不稳定的Web应用程序,但看不到它在localhost
中运行。
我有正在运行的消息,但在浏览器中看不到。
dashboard_1 | lib / main.dart正在http:// localhost:8080
提供
Dockerfile
FROM cirrusci/Flutter AS build
RUN apt update && apt install -y Nginx
RUN Flutter channel beta
RUN Flutter upgrade
RUN Flutter config --enable-web
RUN mkdir /app/
copY . /app/
workdir /app/
RUN Flutter build web
docker-compose.yml
version: '3.1'
services:
dashboard:
build: .
restart: on-failure
ports:
- "8080:8080"
command: >
sh -c "Flutter pub get && Flutter run -d web-server --web-port 8080"
解决方法
我刚刚在--web-hostname 0.0.0.0
命令的末尾添加了docker-compose.yml
,它可以正常工作。但是现在是localhost:8080
,而不是0.0.0.0:8080
。
所以docker-compose.yml
看起来像这样:
version: '3.1'
services:
dashboard:
build: .
restart: always
ports:
- "8080:8080"
command: >
sh -c "flutter pub get && flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0"
,
我在VScode服务器(安装在Google Cloud虚拟机上)上的抖动有类似的问题:
我跑步:
flutter channel beta
flutter upgrade
flutter config --enable-web
flutter build web
flutter pub get && flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0
输出看起来不错:
Running "flutter pub get" in step2_build_flutter_application... 1,071ms
Running "flutter pub get" in step2_build_flutter_application... 1,064ms
Launching lib/main.dart on Web Server in debug mode...
Syncing files to device Web Server... 15.7s
lib/main.dart is being served at http://0.0.0.0:8080
The web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved development workflow.
Warning: Flutter's support for web development is not stable yet and hasn't
been thoroughly tested in production environments.
For more information see https://flutter.dev/web
? To hot restart changes while running,press "r" or "R".
但是,当我尝试Chrome中的以下URL时: http:// external_ip:8080无法访问该站点,并随着超时终止。任何想法,我想念什么?