I have a shiny app that works fine when I run the app through RStudio. Everything loads fine on http://127.0.0.1:xxxx, however I don't see the app when I click on "Open in Browser". Is this a generic issue that has a workaround? If you think the ui and server code is need, I can provide that.
I am trying to fix this above issue because I think this could be the reason that my docker image for this app is not showing up on http://localhost .
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"]
When I run docker run -p 80:80 myimage, i don't get any error message, however I don't see any app on http://localhost. I even went ahead and added a new rule for network on VM Virtual Box, where the guest and host ports are 80, Host IP = 127.0.0.1, Guest IP = 192.168.99.100, and still app doesn't show up on localhost.
Thanks.
Related
All the examples I see online are using docker-compose, but I want to try and run this simple rails application (no db needed) using just the docker run command.
I want to expose the port 3000 so I can view it locally on my laptop in the browser on the same port.
I have this Dockerfile so far:
FROM ruby:2.6-alpine
RUN apk update && apk --update add \
build-base \
nodejs \
postgresql-dev \
tzdata \
imagemagick
# yarn
ENV PATH=/root/.yarn/bin:$PATH
RUN apk add --virtual build-yarn curl && \
touch ~/.bashrc && \
curl -o- -L https://yarnpkg.com/install.sh | sh && \
apk del build-yarn
RUN mkdir /app
WORKDIR /app
RUN gem update --system
RUN gem install bundler
COPY Gemfile Gemfile.lock ./
RUN bundle install --binstubs
CMD ["./puma -C config/puma.rb"]
I was able to build the docker image so far using:
docker build -t my-rails .
What command should I use to run the rails app, detached, exposing the port now?
To run your app in docker run the below command
docker run -d -p 3000:8080(your app port) -v host_volume_or_directory:container_volume -t image_name:tag
just change the port as per your needs, first port will be used with your host machine ip to get the application frontend or this is a expose port. remove the volume part from -v if you don't have any volume to mount. -d means for detached mode.
I created an image of my Shiny app using Docker Toolbox for Windows 7. I used the instructions on this webpage, and when I got to the following command line in Docker terminal, my image won't run:
docker run -p 80:80 myimage
The error that I get is:
chown: invalid.user: shiny.shiny
I searched about this and I think this is due to conflict of users, when shiny is trying to access other files, it can't because some files are available to root. I don't have much experience with using terminal mode and all docker terminal commands.
how can the above issue be sustainably resolved through docker terminal? my next step would be to deploy the docker image on Digital Ocean server, so the Shiny app can be used over a website.
The Dockerfile code is below:
# Install R version 3.5
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
# 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"]
All you need to do is add a 'shiny' user of the group 'shiny'. There are many ways to do it, I decided to create a user with a home folder and also specified the uid and gid, feel free to customise that to your liking. Here's the Dockerfile you should use:
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"]
I deployed my first scala project on docker but i have a problem, the problem is the docker says that the server has been started, but surprisingly it doesn't listen to any request, even i exposed the port to the host, when i tried to request a get, it says that the connection is refused, also i tried to telnet to the port and it seems that there are no listener on port 9000 neither 3200 an 3000, please find bellow what i have wrote in dockerFile
FROM jelastic/sbt
# Env variables
ENV SCALA_VERSION 2.12.4
ENV SBT_VERSION 1.1.0
# Scala expects this file
RUN touch /usr/lib/jvm/java-8-openjdk-amd64/release
# Install Scala
## Piping curl directly in tar
RUN \
curl -fsL https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | tar xfz - -C /root/ && \
echo >> /root/.bashrc && \
echo "export PATH=~/scala-$SCALA_VERSION/bin:$PATH" >> /root/.bashrc
# Install sbt
RUN \
curl -L -o sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get install sbt && \
sbt sbtVersion
WORKDIR /
ADD play /
RUN tree /
EXPOSE 9000
CMD sbt run
and my run command was
docker run -p 9000:9000 -t bee while bee is my image name
as you see the server is started properly.
please find bellow the attached picture to be more clearly
here is the docker ps
If you see your screenshot, it clear states the docker machine is located at 192.168.99.100. So that is the address you need to use.
Open http://192.168.99.100:9000 and it should work
I am new to Docker, I have setup Docker Container on an Amazon Linux box.
I have a docker file which installs tomcat java and a war.
I can see all the installations present in the docker container when I navigate through the container in the exact folders I have mentioned in the Docker file.
When I run the Docker container it says tomcat server has started and I have also tailed the logs so I can see the service is running.
But when I open the host IP URL and 8080 port it says URL can't be reached.
These are the commands to build and run the file which works fine and I can see the status as running.
docker build -t friendly1 .
docker run -p 8080:8080 friendly1
What am I missing here? Request some help on this.
FROM centos:latest
RUN yum -y update && \
yum -y install wget && \
yum -y install tar && \
yum -y install zip unzip
ENV JAVA_HOME /opt/java/jdk1.7.0_67/
ENV CATALINA_HOME /opt/tomcat/apache-tomcat-7.0.70
ENV SAVIYNT_HOME /opt/tomcat/apache-tomcat-7.0.70/webapps
ENV PATH $PATH:$JAVA_HOME/jre/jdk1.7.0_67/bin:$CATALINA_HOME/bin:$CATALINA_HOME/scripts:$CATALINA_HOME/apache-tomcat-7.0.70/bin
ENV JAVA_VERSION 7u67
ENV JAVA_BUILD 7u67
RUN mkdir /opt/java/
RUN wget https://<S3location>/jdk-7u67-linux-x64.gz && \
tar -xvf jdk-7u67-linux-x64.gz && \
#rm jdk*.gz && \
mv jdk* /opt/java/
# Install Tomcat
ENV TOMCAT_MAJOR 7
ENV TOMCAT_VERSION 7.0.70
RUN mkdir /opt/tomcat/
RUN wget https://<s3location>/apache-tomcat-7.0.70.tar.gz && \
tar -xvf apache-tomcat-${TOMCAT_VERSION}.tar.gz && \
#rm apache-tomcat*.tar.gz && \
mv apache-tomcat* /opt/tomcat/
RUN chmod +x ${CATALINA_HOME}/bin/*sh
WORKDIR /opt/tomcat/apache-tomcat-7.0.70/
CMD "startup.sh" && tail -f /opt/tomcat/apache-tomcat-7.0.70/logs/*
EXPOSE 8080
TL;DR: root is not supposed to run GUI app, set a regular user to do so.
I'm trying to run arduino IDE (downloaded, not the package) from within a Docker. I wrote the Dockerfile as follow:
FROM ubuntu:14.04
MAINTAINER Mael Auzias <docker#mael.auzias.net>
ENV HOME /home/arduino
ENV USER arduino
RUN apt-get update && apt-get install -y \
libx11-6 libxext-dev libxrender-dev libxtst-dev \
--no-install-recommends \
&& useradd --create-home --home-dir $HOME $USER \
&& chown -R $USER:$USER $HOME
ADD arduino-1.6.6-linux64.tar.xz $HOME
WORKDIR $HOME/arduino-1.6.6
USER $USER
ENTRYPOINT ["/bin/bash"]
I spent time to understand how does Jessica Frazelle usually starts her graphical containers to rightly start mine with the command:
$docker run --name arduino --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix 25af73b6cb3c ./arduino
No protocol specified
Picked up JAVA_TOOL_OPTIONS:
No protocol specified
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
I installed strace and check with xeyes what was wrong, and I get the following error:
connect(3, {sa_family=AF_LOCAL, sun_path=#"/tmp/.X11-unix/X0"}, 20) = -1 ECONNREFUSED (Connection refused)
Did anyone experience this? Can any point me out some doc or see what I'm doing wrong?
Any help would be welcome.
PS: as specified in the title I do not want to use ssh or VNC. No cryptography should be used nor network when a unix socket is faster and enough.
Solution
Got some news...
As the user root I cannot start graphical application. When I su regular-user and start xterm or xeyes it works. I don't really understand why though :/
Here is the working Dockerfile, tested on Fedora 23.
The application must not be ran as root so it starts using X.
Note that, unrelated to this issue, a Java option has been removed from the bash file arduino (so it starts properly).
After a docker build -t arduino-1.6.6 ., docker run --name arduino --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix arduino-1.6.6 ./arduino start the arduino IDE.
You will not be able to upload any code into an arduino without adding a --device or -v to share the /dev/ttyUSB0.
FROM ubuntu:14.04
MAINTAINER Mael Auzias <docker#mael.auzias.net>
ENV HOME /home/arduino
ENV USER arduino
RUN apt-get update && apt-get install -y \
libx11-6 libxext-dev libxrender-dev libxtst-dev \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --create-home --home-dir $HOME $USER \
&& chown -R $USER:$USER $HOME
ADD arduino-1.6.6-linux64.tar.xz $HOME
RUN sed -i 's/"-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"//g' /home/arduino/arduino-1.6.6/arduino
WORKDIR $HOME/arduino-1.6.6
USER $USER
ENTRYPOINT ["/bin/bash"]
Got some news...
As the user root I cannot start graphical application. When I su regular-user and start xterm or xeyes it works. I don't really understand why though :/
Here is the working Dockerfile, tested on Fedora 23.
The application must not be ran as root so it starts using X.
Note that, unrelated to this issue, a Java option has been removed from the bash file arduino (so it starts properly).
After a docker build -t arduino-1.6.6 ., docker run --name arduino --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix arduino-1.6.6 ./arduino start the arduino IDE.
You will not be able to upload any code into an arduino without adding a --device or -v to share the /dev/ttyUSB0.
FROM ubuntu:14.04
MAINTAINER Mael Auzias <docker#mael.auzias.net>
ENV HOME /home/arduino
ENV USER arduino
RUN apt-get update && apt-get install -y \
libx11-6 libxext-dev libxrender-dev libxtst-dev \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --create-home --home-dir $HOME $USER \
&& chown -R $USER:$USER $HOME
ADD arduino-1.6.6-linux64.tar.xz $HOME
RUN sed -i 's/"-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"//g' /home/arduino/arduino-1.6.6/arduino
WORKDIR $HOME/arduino-1.6.6
USER $USER
ENTRYPOINT ["/bin/bash"]