grunt-open icon indicating copy to clipboard operation
grunt-open copied to clipboard

How to use this plugin on a docker machine?

Open lvarayut opened this issue 9 years ago • 6 comments

This plugin works perfectly on my local machine, however, it doesn't work on my Docker machine. On my local machine the open task set as following:

  server: {
    url: 'http://localhost:<%= express.options.port %>'
  }

On my Docker machine as following:

  server: {
    url: 'http://192.168.99.100:<%= express.options.port %>'
  }

NOTE: 192.168.99.100 is my VM's ip address on my Mac.

I got the following error:

app_1   | Running "open:server" (open) task
app_1   | Warning: Command failed: /bin/sh -c /www/app/node_modules/open/vendor/xdg-open "http://192.168.99.100:3000"
app_1   | /www/app/node_modules/open/vendor/xdg-open: 1: /www/app/node_modules/open/vendor/xdg-open: xdg-mime: not found
app_1   | xdg-open: no method available for opening 'http://192.168.99.100:3000'

I have been googling for a while but still no luck. Any help would be appreciated.

lvarayut avatar Nov 06 '15 11:11 lvarayut

any solution yet?

swateek avatar Feb 09 '16 16:02 swateek

@swateek did you ever find a solution? I am having the same issue

spock123 avatar Aug 23 '16 16:08 spock123

@spock123 let me understand this.. you are running an application on docker where the Gruntfile.js fires a web browser to open.. correct?

If that's the case then it won't work.. the docker doesn't have a UI browser to fire up. What I have done now is - my application is a MEAN stack that has been scaffolded with Yeoman. So I dumped this approach and proceeded to make a distribution build which was hosted on nginx.

If this doesn't work, check for the port that is exposed for the web browser. Expose the same for docker too - not sure if this will work, but might.

swateek avatar Aug 24 '16 05:08 swateek

@swateek yeah, I've now realized why it cannot work.. thanks.. So I just decided to drop it and just start the browser manually. Actually I like this approach better, because the Grunt Open task often opens a new browser window/tab, even if I already have other tabs open on the same page.

spock123 avatar Aug 24 '16 12:08 spock123

Hi guys,

I'm experiencing this issue too, and as the project is not fully in my control I can't just remove grunt-open plugin from the pipeline. Is there any solution to at least ignore this task when there's no browser in the env, or ignore based on some custom ENV variable?

ascrazy avatar Oct 06 '21 07:10 ascrazy

@ascrazy sorry for responding late.. would it be possible to replace the Gruntfile.js with a custom one for yourself?

swateek avatar Oct 21 '21 17:10 swateek