Intermittent container failure (segfault)

We are running a few R applications via Docker containers using ShinyProxy as a front end.

The containers will intermittently launch, but fail right away, causing the “500” error.
Looked at it for quite a while, but could not figure out a pattern. It can launch fine for 10 times and fail on the 11th, or it can fail right away.

I think the issue has to do with Docker/R application specifically. I can reproduce it without ShinyProxy by just running the Docker command.

Here is the stack trace. Any suggestions on how to troubleshoot this would be appreciated. Also, /var/log/messages contains this line during the failures:

kernel: traps: R[11672] general protection ip:7fe04cc33529 sp:7ffc021855b0 error:0 in libc-2.24.so[7fe04cbff000+195000]

Container stack trace:

Listening on http://0.0.0.0:3838

*** caught segfault ***
address (nil), cause ‘unknown’

Traceback:
1: makeTcpServer(host, port, private$appWrapper$onHeaders, private$appWrapper$onBodyData, private$appWrapper$call, private$appWrapper$onWSOpen, private$appWrapper$onWSMessage, private$appWrapper$onWSClose, private$appWrapper$staticPaths, private$appWrapper$staticPathOptions, quiet)
2: .subset2(public_bind_env, “initialize”)(…)
3: WebServer$new(host, port, app, quiet)
4: startServer(host, port, httpuvApp)
5: startApp(appParts, port, host, quiet)
6: shiny::runApp("/root/rpi/app.R", port = 3838, host = “0.0.0.0”)
An irrecoverable exception occurred. R is aborting now …