如何在Digital Ocean Droplet上运行docker映像?

时间:2018-08-26 14:22:00

标签: docker digital-ocean

我在Digital Ocean上安装了Docker并在Ubuntu上安装了Ubuntu,并从桌面上载了docker image.tar文件。我将此image.tar文件上传到/ home / newuser / app目录。接下来,我使用以下命令加载了image.tar:

sudo docker load -i image.tar

图像已加载。我检查了。

运行以下几行时,看不到连接到我的Droplet实例的公共IP上的图像应用程序:

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;
  }
}

和闪亮代码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

1 个答案:

答案 0 :(得分:0)

使用-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 3838
相关问题