docker - 如何在 Digital Ocean 液滴上运行 docker 镜像?
问题描述
我在安装了 Docker 的 Digital Ocean 上有一个基于 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
你们怎么处理这件事?
这是码头文件:
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
解决方案
当您使用 -p 80:80 运行容器时,实际上不需要在 docker 文件中公开端口 80,除非可能是对其他人的提示:https ://forums.docker.com/t/what-is-the-在 docker-file/37726/2 中使用暴露
您可能应该发布您的 shiny-server.conf,但我敢打赌,您要么没有指定端口(在这种情况下,shiny-server 从端口 3838 开始)或 80 以外的端口。确保在配置文件中修改此行:
listen 3838
推荐阅读
- javascript - Javascript 变量 - AJAX - 发送到服务器而不等待答案
- spring-boot - 在 Spring Boot Test 中,如何将临时文件夹映射到配置属性?
- php - 如何使用 MadelineProto 和 php 中的 contacts_ImportedContacts 方法将电话号码添加到电报帐户?
- python - 我在为列表视图设置主键时遇到问题
- ios - GCKUICastButton 在生产中不可见
- javascript - 在没有手动页面刷新的情况下使用 Highway.js 后 JavaScript 不执行
- javascript - Bootstrap 模态不会在路由页面内打开
- c++ - 'QGraphicsVideoItem' 类中的 'offset() 或 setOffset' 的坐标
- operating-system - 操作系统中的SCAN和CSCAN算法
- excel - 从注册表中调用路径以引用文件夹时需要对象错误