Reputation: 77
I have a Ubuntu based droplet on Digital Ocean with Docker installed, and where I uploaded my docker image.tar file from my desktop. I uploaded this image.tar file into /home/newuser/app directory. Next, I loaded the image.tar using following command:
sudo docker load -i image.tar
The image has been loaded. I checked.
When I run these following lines, I can't see my image app on public IP connected to my droplet instance:
sudo docker run image
or
sudo docker run -p 80:80 image
How do you guys go about this?
Here is the 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"]
The code for 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;
}
}
And code for 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
Upvotes: 2
Views: 1910
Reputation: 22553
There's really no need to EXPOSE port 80 in the docker file when you run the container with -p 80:80, except maybe as a hint to others: https://forums.docker.com/t/what-is-the-use-of-expose-in-docker-file/37726/2
You should probably post your shiny-server.conf, but I betcha that you either specified no port (in which case shiny-server starts on port 3838) or a port other than 80. Make sure you modify this line in the config file:
listen 3838
Upvotes: 0