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!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...