Docker Support for HTML2PDF using Node JS

This is just a general community question as I could not find any threads on this that were relevant. But has anyone been able to successfully dockerize a node js server running the HTML2PDF module? I am having a lot of issue doing so, and was just curious if others were able to overcome the missing modules error due to how docker links may differ with how the html2pdf module looks for file paths.

1 Like

Thank you for posting your question to our forum. We will provide you with an update as soon as possible.

1 Like

Thank you for contacting us about this. Just to get more information on the issues you are facing, what errors are you seeing when you are containerizing the module?

1 Like

I am getting this error on “docker-compose up” but if i run npm run build or anything outside of docker it works fine.

I am running on the following npm package: “@pdftron/pdfnet-node”: “10.3.0”.

Here is my Dokcerfile as well:

Build layer

FROM node:20-bullseye-slim AS builder

RUN apt-get update && apt-get install -y --no-install-recommends dumb-init


COPY package*.json ./

RUN npm ci

COPY . .

RUN npm run build

Runtime layer

FROM node:20-bullseye-slim AS server

ENV NODE_ENV production

COPY --from=builder /usr/bin/dumb-init /usr/bin/dumb-init

USER node


COPY --chown=node:node --from=builder /usr/src/app/node_modules /usr/src/app/node_modules

COPY --chown=node:node . /usr/src/app

CMD [“dumb-init”, “node”, “index.js”]


It looks like you are targeting 10.3 version of the SDK which does not support node 20. Instead, please use version 10.7. That should resolve the issue with installing the version of Node.

In addition, the HTML2PDF module requires some additional dependencies as described in this guide. Please ensure that the appropriate packages are installed in the container you are using.