Docker容器无法通过从shinyproxy到数据库的连接启动

flseospp  于 2023-03-07  发布在  Docker
关注(0)|答案(1)|浏览(131)

我想连接一个单独的应用程序在闪亮的代理到码头网络。
shinyproxy上我有几个应用程序,只有一个需要连接到数据库。
它是一个postgresql DB,运行在Docker中的同一台计算机上,该Docker设置为通过网络my-docker-network接收连接
在应用程序.yml中,我应该使用container-network: my-docker-network还是container-network-connections: ["my-docker-network"]
即使我不需要在shiny proxy内部网络,我仍然需要设置'内部网络:真under对接器:“”“
目前容器还没有启动,但是由于容器使用docker run --net my-docker-network --env-file /mypath/.Renviron my_app_image可以自己正常运行,所以可能是连接问题。
我试过各种方法把.Renviron放在不同的地方,但我不认为这是问题所在。
完整的dockerfile(其他应用程序已删除和伪命名):

FROM rocker/r-ver:3.6.3

RUN apt-get update  --allow-releaseinfo-change && apt-get install -y \
    lbzip2 \
    libfftw3-dev \
    libgdal-dev \
    libgeos-dev \
    libgsl0-dev \
    libgl1-mesa-dev \
    libglu1-mesa-dev \
    libhdf4-alt-dev \
    libhdf5-dev \
    libjq-dev \
    liblwgeom-dev \
    libpq-dev \
    libproj-dev \
    libprotobuf-dev \
    libnetcdf-dev \
    libsqlite3-dev \
    libssl-dev \
    libudunits2-dev \
    netcdf-bin \
    postgis \
    protobuf-compiler \
    sqlite3 \
    tk-dev \
    unixodbc-dev \
    libssh2-1-dev \
    r-cran-v8 \
    libv8-dev \
    net-tools \
    libsqlite3-dev \
    libxml2-dev

#for whatever reason it wasn't working
#RUN export ADD=shiny && bash /etc/cont-init.d/add

#install packages
RUN R -e "install.packages(c('somepackages'))"

#copy app script and variables into docker
RUN mkdir /home/app
COPY .Renviron /home/app/
COPY global.R /home/app/
COPY ui.R /home/app/
COPY server.R /home/app/

COPY Rprofile.site /usr/lib/R/etc/

#add run script
CMD ["R", "-e", "shiny::runApp('home/app')"]

应用程序的有用部分.yml
目前,我总是得到“500/容器不响应/运行”在shinyproxy端,即使它运行在独立。

proxy:
  title: apps - page
#  logo-url: https://link/to/your/logo.png
  landing-page: /
  favicon-path: favicon.ico
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  container-wait-time: 40000
  port: 8080
  authentication: simple
  admin-groups: admins
  container-log-path: /etc/shinyproxy/logs
  # Example: 'simple' authentication configuration
  users:
  - name: admin
    password: password
    groups: admins
  - name: user
    password: password
    groups: users
  # Docker configuration
  docker:
    cert-path: /home/none
    url: http://localhost:2375
    port-range-start: 20000
   # internal-networking: true
  specs:
  - id: 06_rshiny_dashboard_r_ver
    display-name: app r_ver container r_app_r_ver
    description: using simple rver set up docker and the r_app_r_ver image
    container-cmd: ["R", "-e", "shinyrunApp('/home/app')"]
    #container-cmd: ["R", "-e", "shiny::runApp('/home/app', shiny.port = 3838, shiny.host = '0.0.0.0')"]
    container-image: asela_r_app_r_ver:latest
    #container-network: my-docker-network
    container-network-connections: [ "my-docker-network" ]
    container-env-file: /home/app/.Renviron
    access-groups: [admins]

logging:
  file:
    name: /etc/shinyproxy/shinyproxy.log

各种注解行显示当前设置,但已尝试使用/不使用

dhxwm5r4

dhxwm5r41#

通过使用一个闪亮的服务器版本的Docker修复了它-不知道为什么,但这解决了一些连接问题。
停靠文件:

FROM rocker/r-ver:3.6.3

RUN apt-get update  --allow-releaseinfo-change && apt-get install -y \
    lbzip2 \
    libfftw3-dev \
    libgdal-dev \
    libgeos-dev \
    libgsl0-dev \
    libgl1-mesa-dev \
    libglu1-mesa-dev \
    libhdf4-alt-dev \
    libhdf5-dev \
    libjq-dev \
    liblwgeom-dev \
    libpq-dev \
    libproj-dev \
    libprotobuf-dev \
    libnetcdf-dev \
    libsqlite3-dev \
    libssl-dev \
    libudunits2-dev \
    netcdf-bin \
    postgis \
    protobuf-compiler \
    sqlite3 \
    tk-dev \
    unixodbc-dev \
    libssh2-1-dev \
    r-cran-v8 \
    libv8-dev \
    net-tools \
    libsqlite3-dev \
    libxml2-dev \
    wget \
    gdebi

##No version control
#then install shiny
RUN wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/VERSION -O "version.txt" && \
    VERSION=$(cat version.txt)  && \
    wget --no-verbose "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
    gdebi -n ss-latest.deb && \
    rm -f version.txt ss-latest.deb

#install packages
RUN R -e "install.packages(c('xtable', 'stringr', 'glue', 'data.table', 'pool', 'RPostgres', 'palettetown', 'deckgl', 'sf', 'shinyWidgets', 'shiny', 'stats', 'graphics', 'grDevices', 'datasets', 'utils', 'methods', 'base'))"

##No version control over

##with version control and renv.lock file

##With version control over

#copy shiny server config over
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf

#avoid some errors
#already in there
#RUN echo 'sanitize_errors off;disable_protocols xdr-streaming xhr-streaming iframe-eventsource iframe-htmlfile;' >> /etc/shiny-server/shiny-server.conf

# copy the app to the image
COPY .Renviron /srv/shiny-server/
COPY global.R /srv/shiny-server/
COPY server.R /srv/shiny-server/
COPY ui.R /srv/shiny-server/

# select port
EXPOSE 3838

# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh

RUN ["chmod", "+x", "/usr/bin/shiny-server.sh"]

# run app
CMD ["/usr/bin/shiny-server.sh"]

application.yml:

proxy:
  title: apps - page
#  logo-url: https://link/to/your/logo.png
  landing-page: /
  favicon-path: favicon.ico
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  container-wait-time: 40000
  port: 8080
  authentication: simple
  admin-groups: admins
  container-log-path: /etc/shinyproxy/logs
  # Example: 'simple' authentication configuration
  users:
  - name: admin
    password: password
    groups: admins
  - name: user
    password: password
    groups: users
  # Docker configuration
  docker:
    cert-path: /home/none
    url: http://localhost:2375
    port-range-start: 20000
   # internal-networking: true
  - id: 10_asela_rshiny_shinyserv
    display-name: ASELA Dash internal shiny server version
    description: container has own shinyserver within it functions on docker network only not on host container-network version
    container-cmd: ["/usr/bin/shiny-server.sh"]
    access-groups: [admins]
    container-image: asela_r_app_shinyserv_ver:latest
    container-network: asela-docker-net

logging:
  file:
    name: /etc/shinyproxy/shinyproxy.log

相关问题