When running docker container with Shiny app, cannot access at 3838

I have a shiny app within a Docker image that I would like to run and view in my browser. When I run the container I am unable to see the shiny app on localhost:3838 (or 127.0.0.1:3838).

My docker compose:

version: '3.8'
services:
  velocity:
    build:
      context: .
      dockerfile: Dockerfile
    image: vapp:latest
    ports:
      - '80:3838'

Then, in the terminal: docker-compose run velocity which, after running through some r code results in the message:

Listening on http://127.0.0.1:4901

However I am unable to see the app either http://127.0.0.1:4901 or http://127.0.0.1:3838.

In case it's relevant, my Dockerfile:

FROM rocker/shiny:4.0.2

COPY app app

RUN apt-get update \
    && apt-get upgrade -y \
    && R --no-save -f app/install.R
    
WORKDIR app

CMD R --no-save -f app.R

How can I run the app and then view it in my browser at localhost:3838?

I found an SO post that was related: How to run R Shiny App in Docker Container - Stack Overflow

From this post, I amended by Dockerfile to be:

FROM rocker/shiny-verse:latest

COPY app app

RUN apt-get update \
    && apt-get upgrade -y \
    && R --no-save -f app/install.R
    
WORKDIR app

EXPOSE 3838

CMD R --no-save -e 'shiny::runApp("app.R", port = 3838, host = "0.0.0.0")'

Then, when I run with docker-compose run velocity, some code runs with the message

Listening on http://0.0.0.0:3838

But, when I visit http://0.0.0.0:3838 I get:

This site can’t be reached
0.0.0.0 refused to connect.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.