1

I want to dockerize my vueJs application. On my local machine I am able to install and serve my application on localhost by running command npm install and npm run serve.

I want to create a docker image so I wrote a dockerfile. My dockerfile looks like this

FROM Image_Name

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["npm", "serve"]

But I am not able to run my docker image with docker run command. Any idea what I am doing wrong.

After running the run command-

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    completion, config, create, ddp, dedupe, deprecate,
    dist-tag, docs, doctor, edit, explore, get, help,
    help-search, hook, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, profile, prune, publish, rb, rebuild, repo, restart,
    root, run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h     quick help on <command>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

[email protected] /usr/lib/node_modules/npm    
4
  • Did you build the container before running using docker build ? Commented Sep 12, 2018 at 11:00
  • Please post your complete docker run command and its output so we can see what's going on. Commented Sep 12, 2018 at 11:00
  • @fxgx yes, i build the container before using it. Commented Sep 12, 2018 at 11:08
  • provide package*.json file Commented Sep 12, 2018 at 11:12

1 Answer 1

1

When you are trying to execute npm run serve you should put CMD ["npm", "run", "serve"] in your Dockerfile. You are missing the run part.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, stupid me , this was bugging me from past 1 hour.
Happens to the best of us :) The error is trying to tell you that you misused the npm command. Good luck for your project!

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.