Healthcheck Instruction Missing

  • Query id: b03a748a-542d-44f4-bb86-9199ab4fd2d5
  • Query name: Healthcheck Instruction Missing
  • Platform: Dockerfile
  • Severity: Low
  • Category: Insecure Configurations
  • URL: Github

Description

Ensure that HEALTHCHECK is being used. The HEALTHCHECK instruction tells Docker how to test a container to check that it is still working
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - dockerfile file
FROM node:alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node","app.js"]

Code samples without security vulnerabilities

Negative test num. 1 - dockerfile file
FROM node:alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1 
CMD ["node","app.js"]