All links open the same app

I dockerized shinyproxy, initially with two basic apps. However, from the main page, both links open the same app (whichever one was first opened). This ran as expected when not dockerized, so maybe there’s something wrong with my network settings? Here is the application.yml file:

proxy:
  title: xx
  logo-url: file:///usr/local/shinyproxy/logo.png
  landing-page: /
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  port: 8080
  authentication: simple
  admin-groups: developers
  shiny.proxy.docker.internal-networking: true
  # 'simple' authentication configuration
  users:
  - name: user
    password: password
    groups: developers
  # Docker configuration
  docker:
    internal-networking: true
  specs:
  - id: test1
    display-name: test1
    description: test1
    container-cmd: ["R", "-e", "shiny::runApp('/apps/app1')"]
    container-image: cmhh/shinyapps
    access-groups: [developers, testers]
    container-network: host
  - id: test2
    display-name: test2
    description: test2
    container-cmd: ["R", "-e", "shiny::runApp('/apps/app2')"]
    container-image: cmhh/shinyapps
    access-groups: [developers, testers]
    container-network: host
logging:
  file:
    shinyproxy.log

This was managed from docker-compose, with the shinyproxy section looking as follows:

version: '3'
services:
  shinyproxy:
    image: "cmhh/shinyproxy"
    container_name: shinyproxy
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    network_mode: "host"
    ports:
      - 8080:8080

Here is the Dockerfile for my shinyproxy container:

FROM openjdk:8-jre

RUN apt-get update && apt-get install -y --no-install-recommends\
    openjdk-8-jre

RUN mkdir /usr/local/shinyproxy 

RUN wget https://www.shinyproxy.io/downloads/shinyproxy-2.0.1.jar -O /usr/local/shinyproxy/shinyproxy.jar

COPY application.yml /usr/local/shinyproxy/

COPY logo.png /usr/local/shinyproxy/

EXPOSE 8080

WORKDIR /usr/local/shinyproxy/

CMD ["java", "-jar", "/usr/local/shinyproxy/shinyproxy.jar"]

Cheers

Chris

Hi @cmhhansen,

I believe the problem here is the use of internal-networking: true in combination with container-network: host.

When internal-networking: true is set, ShinyProxy will not allocate random ports for containers, because it believes it can access containers directly on their exposed port (3838 for shiny apps). However, in network mode host, all containers are using the same host network interface, and only one of them can claim port 3838.

The solution is to create a custom bridge network, like this:

sudo docker network create sp-example-net
1 Like

Hi, I encountered the same problem, with your suggestion, I set container-network: host and it worked perfectly, all my user are using the same R session in the same app.
But another problem showed up, which is :
All of the user’s name are become the same, I use

Sys.getenv("SHINYPROXY_USERNAME")

to get the user name in my app, but when I set container-network: host , all my users name in my app are became the same even though they use different shinyproxy account to login.