Home > Back-end >  Docker container with shiny app listening on localhost
Docker container with shiny app listening on localhost

Time:05-15

I am working with a linux server and I would like to run a docker container with my shiny app, but it is not working. In order to check the problem, I have run my shiny app in RStudio with the following code:

shiny::runApp('/srv/shiny-server/my_app/app', host="0.0.0.0", port=4096)

Then, I can see my app running on the browser an the output in the RStudio console is the following:

...
Listening on http://0.0.0.0:4096

Then, I have run a docker container with my app on the Ubuntu terminal and I have got the same output:

sudo docker run --rm -p 4096:3838 my_app

Listening on http://0.0.0.0:4096

But if I navigate to this address on my browser, I cannot access to my app.

If I write the following on the Ubuntu terminal, I get:

curl localhost:4096

curl: (7) Failed to connect to localhost port 4096

I would appreciate if someone could help me to solve this problem.

CodePudding user response:

The -p xxxx:yyyy parameter on the docker run command maps the internal container port (yyyy) to a port on the host machine (xxxx).

Your app listens on port 4096 which is the internal port. It looks like you want to access the app on localhost:4096, so the host port should also be 4096.

Try

sudo docker run --rm -p 4096:4096 my_app
  • Related