首页 > 解决方案 > 闪亮的服务器 docker 应用程序在本地运行,但在部署到 AWS Fargate 时不运行

问题描述

我有一个容器化的RShiny 应用程序,当它在本地运行时docker run --rm -p 3838:3838 [image]可以按预期工作。当我去的时候会出现“登陆”页面localhost:3838,一切都很好。然而,当这个容器被部署到 AWS Fargate 时,事情就崩溃了。容器似乎已启动并运行,但3838即使3838在 Fargate 中指向所有端口,也没有提供网页服务。

我正在使用 dockerfile

FROM rocker/verse:3.5.1

LABEL Steven "email"

## Add shiny capabilities to container
RUN export ADD=shiny && bash /etc/cont-init.d/add

## Update and install 
RUN tlmgr update --self 
RUN tlmgr install beamer translator

## Add R packages
RUN R -e "install.packages(c('shiny', 'googleAuthR', 'dplyr', 'googleAnalyticsR', 'knitr', 'rmarkdown', 'jsonlite', 'scales', 'ggplot2', 'reshape2', 'Cairo', 'tinytex'), repos = 'https://cran.rstudio.com/')"

#Copy app dir and them dirs to their respective locations
COPY app /srv/shiny-server/ga-reporter
COPY app/report/themes/SwCustom /opt/TinyTeX/texmf-dist/tex/latex/beamer/

#Force texlive to find my custom beamer thems
RUN texhash

EXPOSE 3838

## Add shiny-server information
COPY shiny-server.sh /usr/bin/shiny-server.sh
COPY shiny-customized.config /etc/shiny-server/shiny-server.conf

## Add dos2unix to eliminate Win-style line-endings and run
RUN apt-get update && apt-get install -y dos2unix
RUN dos2unix /usr/bin/shiny-server.sh && apt-get --purge remove -y dos2unix && rm -rf /var/lib/apt/lists/*

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

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

shiny-server.conf

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    app_dir /srv/shiny-server/ga-reporter;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

shiny-server.sh

#!/bin/sh

# ShinyServer: Make sure the directory for individual app logs exists
mkdir -p /var/log/shiny-server
chown -R shiny.shiny /var/log/shiny-server

# RUN ShinyServer
exec shiny-server >> /var/log/shiny-server.log 2>&1

我已经编辑了.conf文件以显示应用程序(即location /),/srv/shiny-server/ga-reporter其中也是我app_dir在 Dockerfile 中复制的位置。Shiny 正在侦听端口3838,应该在那里提供页面。同样,这发生在本地,但在部署到 AWS Fargate 时不会发生。我尝试stdout使用此处提供的第一个答案将Shiny 日志记录到其中,但没有看到生成的任何错误。服务器“健康检查”仅在“专业”版本中提供,因此我无法检查服务器是否实际运行。

在 AWS 上,容器启动并正常运行(即出现“正常”启动日志):

在此处输入图像描述

但是在我希望它被提供的位置根本没有显示页面。

在 dockerhub 上发现了另一个 Shiny 应用程序,它在与 Fargate 集群相同的配置下运行,shiny-server.conf但尝试在其中的文件或文件中实现任何东西都没有运气shiny-server.sh

我错过了什么?Fargate 上的所有内容都指向监听3838;文件中必须有一些我在.conf部署时失败的东西。


编辑

我无法访问 Fargate 上正在运行的容器,因为我无权访问运行 docker 的服务器。

Fargate 有一个接受主机和容器端口的 UI:

在此处输入图像描述


编辑 2 (2018-08-27)

部署它的工程师已经能够解决这个问题:

“是端口改了,我忘了能不能在ALB的安全组上的端口,我只更新了集群的入站规则

所以集群允许连接,但 ALB 安全组不让连接”

标签: rdockershiny-serveraws-fargate

解决方案


推荐阅读