Flutter web的Localhost无法使用docker



我试图运行一个flutter 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命令的末尾,它就可以工作了。但现在是0.0.0.0:8080而不是localhost: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"

最新更新