I have a MySQL database running on Ubuntu and I try to connect to it from a Shiny app running in Shinyproxy (v. 2.5.0). However, I cannot get it to work. Whenever I try to connect to the database I get the 500 Error (Container did not respond in time). The lines that create the error are:
stuffDB <- dbPool(
RMySQL::MySQL(),
user = "USERNAME",
password = "PASSWORD",
dbname = "DB_NAME",
host = "127.0.0.1",
port=3306
)
All the necessary libraries are installed and when I run the application from the container as
sudo docker run -it -p 3838:3838 --network="host" my_docker_image R -e "shiny::runApp('MyApp')"
it works fine. I set docker-network: host
in application.yml to access the host MySQL database. I also tried specifying the socket as container-volumes: ["/var/lib/mysql/mysql.sock:/mysql.sock"]
and tried adding the following lines to MySQL my.conf file:
[client]
protocol=tcp
I have set in application.yml container-network
to host
so that my R application should connect to MySQL server using 127.0.0.0
(or localhost
, I have tried both).
The Rprofile.site file contains
local({
options(shiny.port = 3838, shiny.host = "0.0.0.0")
})