我使用了一个golem管道来打包和修改我的应用程序。
首先,我试图使用docker在windows上本地部署该应用程序(也试图在linux上运行该应用程序,但也有同样的问题)。该应用程序从运行在我的pc上的本地SQlite数据库中收集数据(一旦部署在服务器上,它将是类似的)。
当我作为一个软件包运行应用程序时,应用程序功能正常。但是,一旦我创建了一个停靠映像并运行它,这个应用程序就启动了,但是无法连接到我的本地sql数据库,返回这个错误:无法通过socket '/var/ run /mysqld/mysqld.sock‘(2“没有这样的文件或目录”)连接到本地MySQL服务器。
连接到应用程序中的数据库如下所示:
con = dbConnect(RMariaDB::MariaDB(), dbname = "training_dash_db", user = "root", password = "", host = '127.0.0.1')我的停靠文件如下所示:
FROM rocker/tidyverse:3.5.3
RUN R -e 'install.packages("remotes")'
RUN R -e 'remotes::install_github("r-lib/remotes", ref = "97bbf81")'
RUN R -e 'remotes::install_cran("shiny")'
RUN R -e 'remotes::install_github("Thinkr-open/golem")'
RUN R -e 'remotes::install_cran("processx")'
RUN R -e 'remotes::install_cran("attempt")'
RUN R -e 'remotes::install_cran("DT")'
RUN R -e 'remotes::install_cran("glue")'
RUN R -e 'remotes::install_cran("htmltools")'
RUN R -e 'remotes::install_cran("shinydashboard")'
RUN R -e 'remotes::install_cran("shinydashboardPlus")'
RUN R -e 'remotes::install_cran("lubridate")'
RUN R -e 'remotes::install_cran("dplyr")'
RUN R -e 'remotes::install_cran("purrr")'
RUN R -e 'remotes::install_cran("plotly")'
RUN R -e 'remotes::install_cran("DBI")'
RUN R -e 'remotes::install_cran("tibbletime")'
RUN R -e 'remotes::install_cran("tsibble")'
RUN R -e 'remotes::install_cran("shinyWidgets")'
RUN R -e 'remotes::install_cran("leaflet")'
RUN R -e 'remotes::install_cran("pool")'
RUN R -e 'remotes::install_cran("RMariaDB")'
RUN R -e 'remotes::install_cran("roxygen2")'
COPY K2dashboard_*.tar.gz /app.tar.gz
RUN R -e 'remotes::install_local("/app.tar.gz")'
EXPOSE 80
EXPOSE 3306
CMD R -e "options('shiny.port'=80,shiny.host='0.0.0.0');K2dashboard::run_app()"谢谢。
发布于 2019-11-04 13:40:31
以下是我能看到的问题:
中安装MariaDB驱动程序
以下是解决办法:
http://colinfay.me/r-db/mariadb-rmariadb.html
r-db停靠映像作为源:http://colinfay.me/r-db/,它包含MariaDB:host = "my-network"。有关这方面的信息,请参阅r-db文档:http://colinfay.me/r-db/intro.html#creating-docker-network,以及要从容器内部访问机器上数据库的mariadb部件https://stackoverflow.com/questions/58694187
复制相似问题