8

I have a problem when building docker for vuejs app

I have a vuejs app and now I want to build a docker image for it

This is my Dockerfile

 FROM node:7.7.2-alpine
 WORKDIR /usr/app
 COPY package.json .
 RUN npm install --quiet
 COPY . .
 EXPOSE 8080

And This is my docker-compose.yml file

version: '2'

services:
   web:
      build: .
      command: npm run dev
      volumes:
         - .:/usr/app
         - /usr/app/node_modules
      ports:
         - "8080:8080"

When I run command docker-compose up. I get this result: this result

But when I access the url http://localhost:8080 on my host. I get this: the screen

I don't know exactly what happened. Please help me to fix this problem.

Thank you so much.

These are my source code folders: source code folders

2
  • Can you provide access logs from the app side? Commented Mar 3, 2018 at 13:35
  • @Yuankun: Thanks. My problem is solved Commented Mar 5, 2018 at 4:10

1 Answer 1

5

By default npm run dev binds to localhost only.

Add --host 0.0.0.0 to your webpack-dev-server line in package.json:

From something like:

  "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",

To something like (add --host 0.0.0.0):

    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 0.0.0.0",
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.