Ionic docker Failed to open the browser

I’m using ionic with docker and when i try to execute the command ionic serve that execute the app on the browser i have this error :

root@00209e483f93:/var/www/espaceproold# ionic serve
[INFO] Starting app-scripts server: --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address 0.0.0.0 - Ctrl+C to
       cancel

[13:54:41]  watch started ...
[13:54:41]  build dev started ...
[13:54:41]  clean started ...
[13:54:41]  clean finished in 7 ms
[13:54:41]  copy started ...
[13:54:41]  transpile started ...
[13:54:45]  transpile finished in 3.50 s
[13:54:45]  preprocess started ...
[13:54:45]  deeplinks started ...
[13:54:45]  deeplinks finished in 47 ms
[13:54:45]  preprocess finished in 49 ms
[13:54:45]  webpack started ...
[13:54:45]  copy finished in 4.10 s
[13:54:55]  webpack finished in 10.18 s
[13:54:55]  sass started ...
[13:54:57]  sass finished in 1.55 s
[13:54:57]  postprocess started ...
[13:54:57]  postprocess finished in 18 ms
[13:54:57]  lint started ...
[13:54:57]  build dev finished in 15.37 s
[13:54:57]  watch ready in 15.48 s
[13:54:57]  dev server running: http://localhost:8100/

[13:54:57]  Failed to open the browser: Command failed: xdg-open "http://localhost:8100" /bin/sh: 1: xdg-open: not found
[13:55:00]  lint finished in 3.41 s

docker file :

  • Best practices for certificates in docker
  • Execute “docker run” against created docker swarm cluster
  • How to enable docker API to access via http
  • Bluemix Dev Ops: Building a project with private git submodules
  • how to remove an ENV setting from a docker image
  • Akka and Docker on Marathon
  • FROM ubuntu:16.04
    MAINTAINER ""
    # Install apt packages
    RUN apt-get update && apt-get install -y git lib32stdc++6 lib32z1 curl openjdk-8-jdk-headless sendemail libio-socket-ssl-perl libnet-ssleay-perl && apt-get clean && rm -rf /var/lib/apt/lists/*
    # Install android SDK, tools and platforms 
    RUN cd /opt && curl https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -o android-sdk.tgz && tar xzf android-sdk.tgz && rm android-sdk.tgz
    ENV ANDROID_HOME /opt/android-sdk-linux
    RUN echo 'y' | /opt/android-sdk-linux/tools/android update sdk -u -a -t platform-tools,build-tools-23.0.3,android-23,extra-android-support,extra-google-m2repository,extra-android-m2repository
    # accept the license agreements of the SDK components
    RUN export ANDROID_LICENSES="$ANDROID_HOME/licenses" && \
        [ -d $ANDROID_LICENSES ] || mkdir $ANDROID_LICENSES && \
        [ -f $ANDROID_LICENSES/android-sdk-license ] || echo 8933bad161af4178b1185d1a37fbf41ea5269c55 > $ANDROID_LICENSES/android-sdk-license && \
        [ -f $ANDROID_LICENSES/android-sdk-preview-license ] || echo 84831b9409646a918e30573bab4c9c91346d8abd > $ANDROID_LICENSES/android-sdk-preview-license && \
        [ -f $ANDROID_LICENSES/intel-android-extra-license ] || echo d975f751698a77b662f1254ddbeed3901e976f5a > $ANDROID_LICENSES/intel-android-extra-license && \
        unset ANDROID_LICENSES
    RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
    RUN apt-get install -y -q \
        nodejs \
        gradle \
        && apt-get -y autoclean \
        && rm -rf /var/lib/apt/lists/*
    # Install npm packages
    RUN npm install -g ionic
    RUN npm install -g cordova
    # Setup environment
    ENV ANDROID_HOME /opt/android-sdk-linux
    ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
    EXPOSE 8100 35729
    

    Is there anything wrong with my dockerfile? Or what is the issue?
    thanks in advance !

  • how to deploy .net core web api to linux machine
  • Cannot download Docker images behind a proxy
  • Docker Java Client API Connection Pool
  • AngularJS NOT WORKING in LARAVEL docker continer
  • Docker newbie, is this image created successfully ?
  • Can I maintain the state of a docker container without commiting
  • One Solution collect form web for “Ionic docker Failed to open the browser”

    From ionic documentation, you should run ionic with this option:

    --nobrowser,-b    |    Disable launching a browser
    

    This will prevent ionic serve to try launching a browser to display your site.

    Moreover, you certainly don’t want in production to enable live-reload. you can use --nolivereload then. It’s ok to keep live-reload if you are on a development mode.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.