node.jsxmldockerlibxml-js

Nodejs libxmljs crashes docker container when xml fails schema validation


I'm making a web service in NodeJs that needs to support a specific xml request. So I'm using libxmljs to parse xml and validate it against an xsd.

On my Windows machine everything works well, so when doing this:

isValid = xml.validate(xsd)

isValid will be set as a boolean and xml will have items in the property validationErrors. Everything is fine until I run it in a docker container running node:10.15.2-alpine.

As long as the validation passes, everything is fine, but when there are validation errors, the entire docker container crashes.

I could not find an answer to this when googling so I will provide the answer myself :-)


Solution

  • Change in your Dockerfile to use FROM node:10.15.2-slim and not FROM node:10.15.2-alpine.

    Yes it uses more space, but the alpine edition is appearently not compatible with some of the prebuild python libraries the libxmljs uses.