Hey Everyone,
I have a nodejs app that I put into a docker image and upload to docker hub. I noticed that depending on how I package the code, dockerhub can or can not scan for vulnerabilities. For example, let's say I use this
I can make an image called
But if I comment out the final 3
Then make the image and do the
Based on these outcomes, which one of these statements is true?
a) When only
b) Vulnerabilities do exist in
c) Other?
I welcome any extra insight into the matter because I am completely new to docker and computer coding.
I have a nodejs app that I put into a docker image and upload to docker hub. I noticed that depending on how I package the code, dockerhub can or can not scan for vulnerabilities. For example, let's say I use this
dockerfile to make my docker image.
Code:
FROM node:20-alpine
WORKDIR /api
COPY ./package*.json ./
RUN mkdir ./src
COPY ./src/ ./src/
RUN npm install
# this line makes a binary executable file called run-app
RUN ./node_modules/.bin/pkg ./src/entry.js -o run-app --targets node18-alpine-x64
RUN rm -rf /api/src
RUN rm -rf /api/node_modules
RUN rm -rf /api/package*.json
ENTRYPOINT [ "echo", "'API - binary complete'" ]
my-app and then type the terminal command docker push my-company/my-app. Dockerhub will receive this image and it will say 0 vulnerabilities found.But if I comment out the final 3
RUN ... lines like this:
Code:
...etc...
# this line makes a binary executable file called run-app
RUN ./node_modules/.bin/pkg ./src/entry.js -o run-app --targets node18-alpine-x64
#RUN rm -rf /api/src
#RUN rm -rf /api/node_modules
#RUN rm -rf /api/package*.json
ENTRYPOINT [ "echo", "'API - binary complete'" ]
Then make the image and do the
docker push my-company/my-app, then all of a sudden Dockerhub will receive this image and it will say 20 vulnerabilities found.Based on these outcomes, which one of these statements is true?
a) When only
run-app exists in the image, Dockerhub is absolutely correct in stating there are 0 vulnerabilities. This is because vulnerabilities only exist in /api/<src|modules|package.json>. That act of compiling a binary removes all security vulnerabilities.b) Vulnerabilities do exist in
run-app but Dockerhub does not have the ability to realize this because [_______ something something something _____]c) Other?
I welcome any extra insight into the matter because I am completely new to docker and computer coding.