hawkeye
hawkeye

Reputation: 35732

How to get version of node from docker container?

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?

Upvotes: 6

Views: 28590

Answers (3)

alchi baucha
alchi baucha

Reputation: 1040

You can use the following command to fetch node version running on a specific container.

docker exec <container-name> node -v

Upvotes: 0

Shaik Arif
Shaik Arif

Reputation: 11

you can simply type "docker run node -v"

Upvotes: 1

Jayaram
Jayaram

Reputation: 6606

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'

Upvotes: 6

Related Questions