There are several ways to do this.
1) Add required modules to your project with tests;
2) Mount a directory with required modules in the docker container (see How to mount host directory in docker container?
3) Create your custom docker image based on ours:
RUN cd /opt/testcafe && npm i ua-parser-js
We may be able to provide you with more detailed instructions, but we need some time to try these approaches. Please share your experience once you make any progress here.