question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cant run webpack-dev-server inside of a docker container?

See original GitHub issue

Everything works fine when I want to run this through my local webpack server. I want to pack this project into a docker container.

The main page does get served with all the CSS assets intact, but none of the javascript within seems to have come through. I get this error message on my chrome console:

screen shot 2016-08-03 at 6 20 26 pm

My Dockerfile looks like this:

FROM node

# Prepare app directory
RUN mkdir -p /usr/src/app
ADD . /usr/src/app

# Install dependencies
WORKDIR /usr/src/app
RUN npm install

# Build the app
RUN npm build

# Expose the app port
EXPOSE "80:3000"
EXPOSE 885
EXPOSE 3001

# Start the app
CMD node build/server.js

Im using docker compose with the following config:

web:
  build: .
  ports:
    - '80:3000'
    - '885:885'
    - '3001:3001'
  command: npm start

Do I need to expose any other ports? Is there a workaround to this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

697reactions
merapicommented, Mar 7, 2017

can be helpful for somebody: change the binding address to 0.0.0.0

"start": "node_modules/.bin/webpack-dev-server --host 0.0.0.0", or

  devServer: {
    host: '0.0.0.0',
    port: 80,
    ...
}
209reactions
SpaceK33zcommented, Aug 5, 2016

Did you read “Webpack and Docker for Development and Deployment”? It explains the setup quite well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot run webpack-dev-server inside docker - Stack Overflow
I just want to add something to Raphayol answer if you couldn't enable hot-reloading of webpack-dev-server inside container.
Read more >
Configure Webpack to work inside a container - Okteto
Configure Webpack to work inside a container. Expose webpack's dev server outside the container​. In order to make your app reachable outside the...
Read more >
Running WebpackDevServer in Docker - DEV Community ‍ ‍
Sometimes we want to run webpack-dev-server in a Docker container. The reason might be like following. Want to use a specific Node.js version ......
Read more >
Connection reset with webpack-dev-server inside Docker
The fix is pretty simple, you can either pass in --host 0.0. 0.0 to webpack-dev-server or put in in the aforementioned webpack. config....
Read more >
Docker container doesn't publish port as expected when ...
You need to update your webpack-dev-server (in your package.json command and webpack.config.json ) configuration to bind host to 0.0.0.0 instead of localhost ( ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found