Getting Data In

Why is my node_modules folder deleted after docker build?

leb7abt
Engager

Hi guys!

I'm currently building a docker container with splunk/universalforwarder:7.0.0-monitor-k8s-logs as base image. During my docker build i install my own node.js and want to add my own scriptedinput scripts.

my eventhub folder:

/bin/myscript
/bin/package.json

Dockerfile:

FROM splunk/universalforwarder:7.0.0-monitor-k8s-logs

RUN apt-get update \ 
 && apt-get install curl -y \
 && curl -sL https://deb.nodesource.com/setup_8.x | bash \
 && sudo apt-get install -y nodejs 

COPY eventhub  /opt/splunk/etc/apps/eventhub/

WORKDIR /opt/splunk/etc/apps/eventhub/bin/

RUN npm i --production && ls -al  <==

ls -al gives me that all are successfully created:

myscript
node_modules
package.json
package.json.lock

However running my new image, the node_modules folder and package.json.lock is missing. After doing a manual npm install in the container everything is working.

Copying the files to /opt/splunk/ and doing the npm install there and not to /opt/splunk/etc the files are there.

I think it has something to do with the base image volumes of /opt/splunk/etc and /opt/splunk/etc see: https://github.com/splunk/docker-splunk/blob/master/enterprise/Dockerfile. But i cant't figure out what...I don't run splunk when running the image so i don't know how the volumes getting manipulated and also why only the npm install files getting deleted.

Thanks for your help!

0 Karma
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...