Connect shinyproxy app to external Mongo replica set

I have shinyproxy running in a docker container that is run with docker-compose, which also sets up a docker network called ‘shinyproxy-net’.

The apps run in their own docker containers of course, and the app.yml section for each includes:
container-network: 'shinyproxy-net'
which allows the app containers to reach servers outside of the host server.

That is all happening on an AWS EC2 instance.

On a separate EC2 instance on the same VPC (local subnet) I have a MongoDB server. I pass the local IP address of that server to the R code in each app using a container-env, (in my script-generated app.yml).:


and the R code uses that to connect to the mongo server. THIS ALL WORKS GREAT.

I am now switching to a MongoDB replica set - three servers - for reliability purposes, among other reasons. The low level mongo drivers insist on getting the (locally-defined) hostnames of the replica-set servers and resolving them to IP addresses, even if I provide all three IP addresses as above. To get this to work properly, the app containers need to be able to resolve those names to IP addresses, e.g., something like:


I can get these translations into the shinyproxy server /etc/hosts using extra_hosts: in my shinyproxy server’s docker-compose yml config. But the app containers, where the resolution info is actually needed, cannot access that. This causes the app startup to fail, because the R code cannot connect to the replica-set servers.

I cannot see any way to get this into the app containers’ own /etc/hosts file, with the configuration options provided in the shinyproxy app.yml.

What options are there to achieve this?
Can I add “docker run” arguments for each app in the app.yml - so I can include --add-host flags?


Can I add “docker run” arguments for each app in the app.yml - so I can include --add-host flags?

This currently not possible.

To be honest, I currently don’t see a solution for this within ShinyProxy.

AWS has a feature for private DNS records, maybe this could help?

I was able to get this to work as follows:

  • Put the host/IP translations in /etc/hosts on theserver running the shinyproxy and app docker containers
  • Upgraded that server to ubuntu 20.04 (had been running 18.04). The systemd-resolved in 20.04 appears to correctly load the /etc/hosts and serve them into the docker network’s dns somehow such that within each container they resolve.

Prior to 20.04 this did not work correctly and I had to jump through various hoops to get it working.