首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在数字海洋水滴上运行docker图像?

如何在数字海洋水滴上运行docker图像?
EN

Stack Overflow用户
提问于 2018-08-26 22:22:00
回答 1查看 877关注 0票数 1

我有一个基于Ubuntu的液滴在数字海洋上安装了Docker,并在那里我上传了我的docker image.tar文件从我的桌面。我将这个image.tar文件上传到/home/newuser/app目录中。接下来,我使用以下命令加载image.tar:

代码语言:javascript
复制
sudo docker load -i image.tar

图像已加载。我查过了。

当我运行以下代码行时,我看不到公网IP上的图像应用程序连接到我的droplet实例:

代码语言:javascript
复制
sudo docker run image

代码语言:javascript
复制
sudo docker run -p 80:80 image

你们是怎么做的?

这是dockerfile:

代码语言:javascript
复制
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的代码:

代码语言:javascript
复制
# 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的代码:

代码语言:javascript
复制
# 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
EN

回答 1

Stack Overflow用户

发布于 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的端口。确保在配置文件中修改以下行:

代码语言:javascript
复制
listen 3838
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52027145

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档