Citizen
Citizen

Reputation: 121

Docker container with shiny app listening on localhost

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.

Upvotes: 0

Views: 944

Answers (1)

Hans Kilian
Hans Kilian

Reputation: 25179

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

Upvotes: 1

Related Questions