6

To get a node version - I expect to run the following:

node --version

I'm running the following with docker:

docker run node:4-onbuild -v

I get this:

docker: Error response from daemon: Container command '--version' not found or does not exist..

My question is: How to get version of node from docker container?

Community
  • 1
  • 1
hawkeye
  • 33,004
  • 28
  • 141
  • 288
  • 1
    Could you try `docker run -it --rm node /bin/bash -c 'node --version'` – Kannaj Mar 08 '17 at 12:41
  • your command `docker run node:4-onbuild -v` does launch a node:4 docker container, and tries to launch the command `-v` which is not a valid bash command, see Kunkka's answer – user2915097 Mar 08 '17 at 13:06

1 Answers1

2

you need to specifically ask docker to run -v within the node container like below

docker run -it --rm node /bin/bash -c 'node --version'
Kannaj
  • 5,648
  • 10
  • 35
  • 70
  • 1
    In case one uses `node:alpine` or other distributions who have no `bin/bash` available, you can use `docker run -it --rm node:alipne node`. It will start node console with version info in the first line. – Tzahi Leh Aug 11 '20 at 08:42