Connecting to local docker network for individual app/container

I want to connect an individual app within shiny proxy to a docker network.

I have a few apps on shinyproxy, only one needs to connect to the database.

It is a postgresql DB running on the same machine in a docker set up to receive connections though the network my-docker-network

In application.yml Should I use
container-network: my-docker-network
or
container-network-connections: ["my-docker-network"]
?

Even I don’t need internal networks in shiny proxy do I still need to set internal-networking: true under docker:

At the moment the container isn’t starting, but as the container runs fine by itself using docker run --net my-docker-network --env-file /mypath/.Renviron my_app_image it seems to be a connection issue.

Could this be an issue with the loading of the .Renviron? I have checked other approaches and don’t mind the .Renviron being accessible within the container.

Full dockerfile (other stuff deleted):

FROM rocker/r-ver:3.6.3

RUN apt-get update  --allow-releaseinfo-change && apt-get install -y \
    lbzip2 \
    libfftw3-dev \
    libgdal-dev \
    libgeos-dev \
    libgsl0-dev \
    libgl1-mesa-dev \
    libglu1-mesa-dev \
    libhdf4-alt-dev \
    libhdf5-dev \
    libjq-dev \
    liblwgeom-dev \
    libpq-dev \
    libproj-dev \
    libprotobuf-dev \
    libnetcdf-dev \
    libsqlite3-dev \
    libssl-dev \
    libudunits2-dev \
    netcdf-bin \
    postgis \
    protobuf-compiler \
    sqlite3 \
    tk-dev \
    unixodbc-dev \
    libssh2-1-dev \
    r-cran-v8 \
    libv8-dev \
    net-tools \
    libsqlite3-dev \
    libxml2-dev

#for whatever reason it wasn't working
#RUN export ADD=shiny && bash /etc/cont-init.d/add

#install packages
RUN R -e "install.packages(c('somepackages'))"

#copy app script and variables into docker
RUN mkdir /home/app
COPY .Renviron /home/app/
COPY global.R /home/app/
COPY ui.R /home/app/
COPY server.R /home/app/

COPY Rprofile.site /usr/lib/R/etc/

#add run script
CMD ["R", "-e", "shiny::runApp('home/app')"]

`

useful parts of the application.yml

proxy:
  title: apps - page
#  logo-url: https://link/to/your/logo.png
  landing-page: /
  favicon-path: favicon.ico
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  container-wait-time: 40000
  port: 8080
  authentication: simple
  admin-groups: admins
  container-log-path: /etc/shinyproxy/logs
  # Example: 'simple' authentication configuration
  users:
  - name: admin
    password: password
    groups: admins
  - name: user
    password: password
    groups: users
  # Docker configuration
  docker:
    cert-path: /home/none
    url: http://localhost:2375
    port-range-start: 20000
   # internal-networking: true
  specs:
  - id: 06_rshiny_dashboard_r_ver
    display-name: app r_ver container r_app_r_ver
    description: using simple rver set up docker and the r_app_r_ver image
    container-cmd: ["R", "-e", "shinyrunApp('/home/app')"]
    #container-cmd: ["R", "-e", "shiny::runApp('/home/app', shiny.port = 3838, shiny.host = '0.0.0.0')"]
    container-image: asela_r_app_r_ver:latest
    #container-network: my-docker-network
    container-network-connections: [ "my-docker-network" ]
    container-env-file: /home/app/.Renviron
    access-groups: [admins]

logging:
  file:
    name: /etc/shinyproxy/shinyproxy.log

Various commented out lines show the current set up but have tried with/without

Fixed by including shiny-server in the dockerfile and running the app through the shiny cmd.

Either configuration of the network works to connect to database.

Dockerfile:

FROM rocker/r-ver:3.6.3

RUN apt-get update  --allow-releaseinfo-change && apt-get install -y \
    lbzip2 \
    libfftw3-dev \
    libgdal-dev \
    libgeos-dev \
    libgsl0-dev \
    libgl1-mesa-dev \
    libglu1-mesa-dev \
    libhdf4-alt-dev \
    libhdf5-dev \
    libjq-dev \
    liblwgeom-dev \
    libpq-dev \
    libproj-dev \
    libprotobuf-dev \
    libnetcdf-dev \
    libsqlite3-dev \
    libssl-dev \
    libudunits2-dev \
    netcdf-bin \
    postgis \
    protobuf-compiler \
    sqlite3 \
    tk-dev \
    unixodbc-dev \
    libssh2-1-dev \
    r-cran-v8 \
    libv8-dev \
    net-tools \
    libsqlite3-dev \
    libxml2-dev \
    wget \
    gdebi

##No version control
#then install shiny
RUN wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/VERSION -O "version.txt" && \
    VERSION=$(cat version.txt)  && \
    wget --no-verbose "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
    gdebi -n ss-latest.deb && \
    rm -f version.txt ss-latest.deb

#install packages
RUN R -e "install.packages(c('xtable', 'stringr', 'glue', 'data.table', 'pool', 'RPostgres', 'palettetown', 'deckgl', 'sf', 'shinyWidgets', 'shiny', 'stats', 'graphics', 'grDevices', 'datasets', 'utils', 'methods', 'base'))"

##No version control over

##with version control and renv.lock file

##With version control over

#copy shiny server config over
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf

#avoid some errors
#already in there
#RUN echo 'sanitize_errors off;disable_protocols xdr-streaming xhr-streaming iframe-eventsource iframe-htmlfile;' >> /etc/shiny-server/shiny-server.conf

# copy the app to the image
COPY .Renviron /srv/shiny-server/
COPY global.R /srv/shiny-server/
COPY server.R /srv/shiny-server/
COPY ui.R /srv/shiny-server/

# select port
EXPOSE 3838

# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh

RUN ["chmod", "+x", "/usr/bin/shiny-server.sh"]

# run app
CMD ["/usr/bin/shiny-server.sh"]

application.yml:

proxy:
  title: apps - page
#  logo-url: https://link/to/your/logo.png
  landing-page: /
  favicon-path: favicon.ico
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  container-wait-time: 40000
  port: 8080
  authentication: simple
  admin-groups: admins
  container-log-path: /etc/shinyproxy/logs
  # Example: 'simple' authentication configuration
  users:
  - name: admin
    password: password
    groups: admins
  - name: user
    password: password
    groups: users
  # Docker configuration
  docker:
    cert-path: /home/none
    url: http://localhost:2375
    port-range-start: 20000
   # internal-networking: true
  - id: 10_asela_rshiny_shinyserv
    display-name: ASELA Dash internal shiny server version
    description: container has own shinyserver within it functions on docker network only not on host container-network version
    container-cmd: ["/usr/bin/shiny-server.sh"]
    access-groups: [admins]
    container-image: asela_r_app_shinyserv_ver:latest
    container-network: asela-docker-net

logging:
  file:
    name: /etc/shinyproxy/shinyproxy.log