I have two vuejs projects one is using vue-cli-service and the other is using webpack-dev-server. I have build a docker image for both.
Project 1 (package.json)
"scripts": {
"serve": "vue-cli-service serve",
And I can run a container from the corresponding image with:
docker run -it -p 8081:8080 -v ${PWD}:/app/ -v /app/node_modules --name project-one project-one-image
Project 2 (package.json)
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
And I can run a container from the corresponding image with:
docker run -it -p 8081:8080 -e "HOST=0.0.0.0" -v ${PWD}:/app/ -v /app/node_modules --name project-two project-two-image
It took me some time to figure out that the webpack version I had to specify: -e "HOST=0.0.0.0" for the docker run command (or set it in the index.js file). But its described in a few places:
https://webpack.js.org/configuration/dev-server/#devserverhost
Docker container running vue-cli Welcome Page on localhost: This site can’t be reached
But why is that not necessary for vue-cli-service serve is it hardcoded somewhere to use 0.0.0.0 (its not being set anywhere in my sourcefiles)?