-1

I am looking for a Docker image that is just some *nix flavor with NPM and Node.js installed.

This image

https://hub.docker.com/_/node/

requires that a package.json file is present, and the Docker build uses COPY to copy the package.json file over, and it also looks for a Node.js script to start when the build is run.

...I just need a container to run a shell script using this technique:

docker exec mycontainer /path/to/test.sh

Which I discovered via:

Running a script inside a docker container using shell script

I don't need a package.json file or a Node.js start script, all I want is

  1. a container image
  2. Node.js and NPM installed

Does anyone know if there is an a Docker image for Node.js / NPM that does not require a package.json file? Perhaps I should just use a plain old container image and just add the code to install Node myself?

2
  • Thanks, I just want to run some tests in the container. Turns out I can use the start script of the package.json file to run the bash script in question. But I don't really need that package.json file. The only things I need (1) a container, (2) NPM and node.js installed. Commented Nov 23, 2016 at 10:00
  • Added an answer, seems to work for my needs. Commented Nov 24, 2016 at 4:27

1 Answer 1

0

Alright, I tried to make this a simple question, unfortunately nobody could provide a simple answer...until now!

Instead of using this base image:

FROM node:5-onbuild

We use this instead:

FROM node:5

I read about onbuild and could not figure out what it's about, but it adds more than I needed for my use case.

the below code is in our Dockerfile

# 1. start with this image as a base
FROM node:5

# 2. copy the script from real-life into the container (magic)
COPY script.sh /usr/src/app/ 

# 3. define container entry point which will run our script 
ENTRYPOINT ["/bin/bash", "/usr/src/app/script.sh"]

you build the docker image like so:

docker build -t foo .

then you run the image like so, which will "run the entrypoint":

docker run -it --rm foo

The container stdout should stream to the terminal where you ran docker run which is good (am I asking too much?).

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.