Access local mongo database from container


#1

Hi, Really enjoying using shinyproxy and making some good progress developing an app. I have hit a brick wall trying to connect to a mongo database that is on the same server but outside the app container. I have tried to use docker-network: host but this doesn’t seem to unlock it. I’m using mongolite to make the connection from with my app.

My yml file is below, any suggestions or pointers would be much appreciated.

shiny:
proxy:
title: DataMuster
logo-url: file:///Webstuff/DM1.png
landing-page: /
heartbeat-rate: 10000
heartbeat-timeout: 60000
port: 8080
authentication: simple
admin-groups: scientists
# Example: ‘simple’ authentication configuration
users:
- name: jack
password: password
groups: scientists
- name: jeff
password: password
groups: mathematicians
# Example: ‘ldap’ authentication configuration
ldap:
url: ldap://ldap.forumsys.com:389/dc=example,dc=com
user-dn-pattern: uid={0}
group-search-base:
group-search-filter: (uniqueMember={0})
manager-dn: cn=read-only-admin,dc=example,dc=com
manager-password: password
# Docker configuration
docker:
cert-path: /home/none
url: 127.0.0.1:27017
host: 127.0.0.1
port-range-start: 20000
server:
contextPath: /
#volumes:

- ~shinyproxy/target/root/test

apps:

  • name: DataMuster
    display-name: Data Muster Demo
    docker-cmd: [“R”, “-e shiny::runApp(’/root/BelmontDataMuster’)”]
    docker-image: beldatamuster/demoapp
    groups: scientists
    docker-network: host

logging:
file:
shinyproxy.log


#2

You probably want to take look at this thread Best practice of using database


#3

Ok, thanks. I’ll give it a go, I was trying to get away with using existing infrastructure but this solution looks like it will provide some longer term benefits. I’ll let you know how I go. Thanks.


#4

Thanks for your suggestion, it works really well. It took me a bit of time to understand container networks and I had some issues using mongolite. In the end the mongolite issue turned out to be a dependency issue in the main Docker file, it took me a bit of time to chase down the issue but once I found the problem and added the dependency it worked perfectly.

Once again thanks for your help.

Best wishes,

Dave