我有一个基于Ubuntu的液滴在数字海洋上安装了Docker,并在那里我上传了我的docker image.tar文件从我的桌面。我将这个image.tar文件上传到/home/newuser/app目录中。接下来,我使用以下命令加载image.tar:
sudo docker load -i image.tar图像已加载。我查过了。
当我运行以下代码行时,我看不到公网IP上的图像应用程序连接到我的droplet实例:
sudo docker run image或
sudo docker run -p 80:80 image你们是怎么做的?
这是dockerfile:
FROM r-base:3.5.0
# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev/unstable \
libxt-dev \
libssl-dev
# Add shiny user
RUN groupadd shiny \
&& useradd --gid shiny --shell /bin/bash --create-home shiny
# Download and install ShinyServer
RUN wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.7.907-amd64.deb && \
gdebi shiny-server-1.5.7.907-amd64.deb
# Install R packages that are required
RUN R -e "install.packages(c('Benchmarking', 'plotly', 'DT'), repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('shiny', repos='https://cloud.r-project.org/')"
# Copy configuration files into the Docker image
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/
# Make the ShinyApp available at port 80
EXPOSE 80
# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]shiny-server.conf的代码:
# Define the user we should use when spawning R Shiny processes
run_as shiny;
# Define a top-level server which will listen on a port
server {
# Instruct this server to listen on port 80. The app at dokku-alt need expose PORT 80, or 500 e etc. See the docs
listen 80;
# Define the location available at the base URL
location / {
# Run this location in 'site_dir' mode, which hosts the entire directory
# tree at '/srv/shiny-server'
site_dir /srv/shiny-server;
# Define where we should put the log files for this location
log_dir /var/log/shiny-server;
# Should we list the contents of a (non-Shiny-App) directory when the user
# visits the corresponding URL?
directory_index on;
}
}shiny-server.sh的代码:
# Make sure the directory for individual app logs exists
mkdir -p /var/log/shiny-server
chown shiny.shiny /var/log/shiny-server
exec shiny-server >> /var/log/shiny-server.log 2>&1发布于 2018-08-27 22:18:54
当您使用-p 80:80运行容器时,实际上不需要在docker文件中公开端口80,可能只是作为对其他人的提示:https://forums.docker.com/t/what-is-the-use-of-expose-in-docker-file/37726/2
您可能应该发布shiny-server.conf,但我打赌您要么没有指定端口(在这种情况下,shiny-server在端口3838上启动),要么指定了一个不是80的端口。确保在配置文件中修改以下行:
listen 3838https://stackoverflow.com/questions/52027145
复制相似问题