Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support #143

Closed
geddski opened this issue Mar 28, 2015 · 80 comments
Closed

Docker support #143

geddski opened this issue Mar 28, 2015 · 80 comments

Comments

@geddski
Copy link

geddski commented Mar 28, 2015

currently when running webpack dev server inside of a docker container, the changes to the source files are not picked up by webpack, so no compilation happens.

Using boot2docker vm on OSX.

@crestenstclair
Copy link

+1 having the exact same issue, would appreciate an update

Is essentially this issue:

remy/nodemon#419

@Rodeoclash
Copy link

+1

1 similar comment
@bradbarrow
Copy link

+1

@yvann
Copy link

yvann commented May 28, 2015

+1 the same for me, I can't use it.

@evandegr
Copy link

+1

4 similar comments
@myzone
Copy link

myzone commented May 31, 2015

+1

@muraken720
Copy link

+1

@joernroeder
Copy link

+1

@johnknaack
Copy link

+1

@saulshanabrook
Copy link

Use this project: https://github.com/brikis98/docker-osx-dev

It picks up file changes events

@tomchentw
Copy link

docker-osx-dev works great for me. Also its woking well with piping.

@lily-mara
Copy link

I am having the same problem, but I feel it's for a different reason. I'm using the --host 0.0.0.0 option to allow the server to listen on all interfaces, but when used in conjunction with the --hot flag, this causes problems. The hot reloader uses the provided host to create an absolute url instead of using a relative url, so all of my reloading ajax calls are going to http://0.0.0.0:8080/socket.io/ instead of just socket.io/, which would work no matter what the host/port was. I'm also proxying the server behind nginx that happens to be running on the same port, but if I wasn't, then this issue would be even worse.

@xaviervia
Copy link

+1

1 similar comment
@vectart
Copy link

vectart commented Jul 23, 2015

+1

@xaviervia
Copy link

@natemara about your issue, I worked around that by setting the config:

module.exports = {
  entry: {
    app: [
      "webpack-dev-server/client?:8080/",
      'webpack/hot/dev-server',
      "./src/app.coffee"
    ]
  }
}

...buuut, big disclaimer, it just fixed the socket.io address, not the livereload, which is still not working (webpack doesn't rebuild the files)

@fordlee404
Copy link

+1

3 similar comments
@plouc
Copy link

plouc commented Aug 14, 2015

+1

@svenhornberg
Copy link

+1

@jweidler
Copy link

jweidler commented Sep 1, 2015

+1

@ghost
Copy link

ghost commented Sep 11, 2015

The problem has been sovled by Mark Wolfe, I have tested it in my MacBookPro.

@fordlee404
Copy link

I fixed the problem with webpack config:

watchOptions: {
    poll: true
}

@FZX thanks!

@vyorkin
Copy link

vyorkin commented Nov 21, 2015

@sokra I believe it's not related to webpack-dev-server. It's just vboxfs that doesn't support fsevents or inotify.

@vyorkin
Copy link

vyorkin commented Nov 21, 2015

@geddski p.s.: here is a good post about dev env with docker on OS X. My solution is to just set poll: true or if polling is too slow for you use smth like dinghy.

@langri-sha
Copy link

+1

@jimthedev
Copy link

Seems like this should probably be closed since the problem is with Virtual Box's (likely reasonable) decision to not pass through inotify events. The current relatively common fix is to use https://github.com/brikis98/docker-osx-dev

This is true for anyone using node, python, or any other language in docker who wants watchers. It really has little to do with Webpack. Perhaps it just needs to be documented, but there's little to do from a code standpoint.

@langri-sha
Copy link

@jimthedev, apparently it's not even related to just vboxsf. It is a known issue for all NFS mounts.

Here is an excerpt from the PM2 documentation:

When working with NFS devices you'll need to set usePolling: true as stated in this chokidar issue.

It seems that the best course of action is to make this information more prominent by putting it in the documentation where suitable, as you suggest.

@jimthedev
Copy link

@langri-sha, the tricky part of documenting/educating on this is that polling has implications for large project structures. It isn't always the best option. In some scenarios it might be ideal, in others, a better option might be to use docker-osx-dev to marshall the diff'ing through alternative means while leaving your webpack config untouched.

@marlonbernardes
Copy link

Thanks @fordlee404, setting watchOptions also worked for me!

watchOptions: {
    poll: true
}

@nrempel
Copy link

nrempel commented May 13, 2016

I believe this is an issue with docker (caused by virtual box and other virtualization tools not supporting inotify events), not webpack-dev-server.

There is a proposed solution here: moby/moby#18246

@jimthedev
Copy link

You are correct. This is an issue with Virtual Box.

@max-mykhailenko
Copy link

With new docker all works fine, My problem was in using volumes_from instead of volumes in docker-compose.yaml for node container

@enjikaka
Copy link

enjikaka commented Sep 14, 2016

I'm still having issues with webpack-dev-server in docker with docker-compose and nginx-proxy.

version: '2'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
  web-dev:
    build: .
    working_dir: /app
    volumes:
      - "./:/app"
      - /app/node_modules
    expose:
      - 9090
    environment:
      - NODE_ENV=development
      - VIRTUAL_HOST=app.dev
    command: npm run web:dev
    depends_on:
      - nginx-proxy

npm run web:dev === webpack-dev-server --config webpack/webpack.config.web.dev.js --hot --inline --watch-poll

All I get is this from nginx-proxy when trying to visit app.dev in the browser;

2016/09/14 11:04:04 [error] 33#33: 
*9 connect() failed (111: Connection refused) while connecting to upstream, 
client: 172.18.0.1, 
server: app.dev, request: "GET / HTTP/1.1", 
upstream: "http://172.18.0.4:9090/", 
host: "app.dev"

webpack-dev-server doesn't seem to allow connection or something? An express server instead of the webpack-dev-server works fine.

@SpaceK33z
Copy link
Member

@enjikaka: you need to add --host 0.0.0.0 to your webpack-dev-server command. By default it only allows connections from localhost.

@enjikaka
Copy link

@SpaceK33z Thanks, that made it work!

@nickdima
Copy link

Quick question for people using webpack in docker for development. Isn't it slow for non trivial apps with lots of files? After all it's running inside a VM.

@langri-sha
Copy link

langri-sha commented Oct 21, 2016

Yes, compared to running in your host environment, the typical setup will be slower, especially if you're using a hosted hypervisor. It's mostly impacting me on the first run and file transfers, but with proper caching these issues usually dissolve with the ease of running everything at once (development server, test runners, etc).

@enjikaka
Copy link

enjikaka commented Oct 22, 2016

@nickdima We use webpack inside Docker for deving at TIDAL. (Pretty huge app) I've only tried in on my Windows machine so fat though. Works great there. :)

@bigmassa
Copy link

bigmassa commented Nov 3, 2016

Not sure if this is related but I have been having a similar issue with running webpack and docker.
Scenario is on osx running webpack --watch from host to build my angular project which is linked in via a volume regularly crashes the container when it detects a file change. Similarly on ubuntu the container does not crash but the webpack --watch fails to recognise there is a change (which led me here).

I have found that increasing the number of file watchers in both os's have totally fixed my issues. For ubuntu by increasing the amount of inotify watchers https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers and for osx ive been running sudo webpack --watch.

Again this may not help but may help but thought it was a good idea to post anyway.

@evfreethy
Copy link

evfreethy commented Mar 26, 2017

Anybody using RubyMine or a JetBrains IDE - please see @bartvanremortele's comment to fix this issue

luisnaranjo733 added a commit to ddmiller1995/InForm that referenced this issue Mar 27, 2017
There was a bug on Windows machines (not OSX) where changes to source
code weren't getting picked up by the hotloader, even though the hot
loader was running. The fix was to enable polling in the hot loader
server config
(webpack/webpack-dev-server#143 (comment))

I also fixed the links to the static files in the html template to point
to the /static/ nginx path

I also refactored the two docker files into a folder, so they aren't
just floating around at the project root
@jackbraj
Copy link

jackbraj commented Apr 28, 2017

I also have the same problem using laravel-mix which runs webpack.
I am using it inside docker container and my editor is phpstorm on Mac Sierra.

markevans added a commit to markevans/docker-rails-elm-skeleton that referenced this issue Jun 29, 2017
@Angelinsky7
Copy link

Angelinsky7 commented Jul 27, 2017

For those interested (on Window), i'm currently working on a solution inspired by another....
You can try it at https://github.com/Angelinsky7/Docker-Volume-Watcher/releases and let me know.
it uses a filewrapper and sends notification to the docker volume container

@patroza
Copy link

patroza commented Sep 17, 2017

@Angelinsky7 you're a genius! thanks a lot!

@Angelinsky7
Copy link

@patroza :-)

@cristianfraser
Copy link

@SpaceK33z Was a Docker section added with the docs overhaul that I'm missing or not?

marcellodesales added a commit to intuit/intuit-spring-cloud-config-inspector that referenced this issue Nov 22, 2017
…g Server

Adding the full support for running the config inspector using Docker Compose.
This incluedes setting up and running.

*	new file:   .dockerignore
- Never add those dirs to the image while building using Dockerfile

*	new file:   Dockerfile
- Reusable image for both the inspector and proxy servers

*	new file:   docker-compose.yml
- Declaring all the servers in that can be used
- NOTE: Running in docker means the config server MUST be added
  to the UI as "http://config-server:8888", as the call goes through
  the Config Proxy.

*	modified:   package.json
- Adding more scripts to run the the proxy and app as in containers
- Webpack in container see
   webpack/webpack-dev-server#143 (comment)

*	modified:   README.md
- Updating the README
@magicsgxie
Copy link

magicsgxie commented Jun 26, 2018

In the remote server(centos7), I use command (npm run dev) to start webpack-dev-server, when I close the session, the "webpack-dev-server" is closing. How can i solve this probleam?
the dev's config like this
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests