jsoverson / grunt-open

Open urls and files from a grunt task
MIT License
109 stars 19 forks source link

How to use this plugin on a docker machine? #32

Open lvarayut opened 9 years ago

lvarayut commented 9 years ago

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.

swateek commented 8 years ago

any solution yet?

spock123 commented 8 years ago

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

swateek commented 8 years ago

@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.

spock123 commented 8 years ago

@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.

ascrazy commented 3 years ago

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?

swateek commented 3 years ago

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