0

I was trying to run a flutter web application but I can't see it running in localhost. I have this message that is running but I can't see it in my browser.

dashboard_1 | lib/main.dart is being served at 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"
1
  • 1
    If an application prints out "listening on localhost" at startup, it probably won't be reachable from outside the container; you need to reconfigure it somehow to listen to (or set the bind address to) 0.0.0.0 instead. See for example Why 0.0.0.0 is working and localhost or 127.0.01 is not. Commented Nov 6, 2020 at 14:15

1 Answer 1

2

I just added --web-hostname 0.0.0.0 to end of the docker-compose.yml command and it works. But instead of localhost:8080 now is 0.0.0.0:8080.

So the docker-compose.yml looks like this:

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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.