TL;DR
I need to kick off Selenium from a Java application running in the background in a Docker container. The kick off fails because the X11 environment is not accessible during runtime. See Dockerfile
below that I am starting with.
What should I do?
Problem
I am starting with a simple Dockerfile
that installs Java 8 and Jetty 9.3.x to run a simple service (Selenium stuff, actually). The service is actually set up to kick off some things that require a UI in order to execute. The problem I am having is that the execution of anything in there fails because the UI is not available in the configuration I have running. I have some other things running with supervisord
, but this is the basic setup:
Dockerfile
FROM ubuntu:16.04
RUN apt-get update -y && \
apt-get install -y software-properties-common wget supervisor && \
mkdir -p /var/log/supervisor && \
mkdir -p /etc/supervisor/conf.d
RUN useradd -Ums /bin/bash jetty
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y oracle-java8-installer && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/oracle-jdk8-installer
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
ENV JETTY_VERSION "9.3.7.v20160115"
ENV JETTY_HOME "/opt/jetty"
RUN wget -q -O /opt/jetty.tgz "http://download.eclipse.org/jetty/${JETTY_VERSION}/dist/jetty-distribution-${JETTY_VERSION}.tar.gz" && \
cd /opt && \
tar -zxvf /opt/jetty.tgz && \
rm /opt/jetty.tgz && \
mv "/opt/jetty-distribution-${JETTY_VERSION}" "${JETTY_HOME}" && \
chown -R jetty:jetty "${JETTY_HOME}"
ADD supervisor.conf /etc/supervisor.conf
ADD jetty.sv.conf /etc/supervisor/conf.d/jetty.sv.conf
CMD ["supervisord", "-c", "/etc/supervisor.conf"]
jetty.sv.conf
[program:jetty]
command=/usr/bin/java -jar /opt/jetty/start.jar jetty.home=/opt/jetty jetty.base=/opt/jetty
redirec_stderr=true
startsecs=5
I want to ensure that everything runs in a UI environment rather than in the headless environment.
What I Tried
I tried using the VNC and shared desktop setup as in these:
- Can you run GUI apps in a docker container?
- https://github.com/dockerfile/ubuntu-desktop
- https://github.com/fcwu/docker-ubuntu-vnc-desktop
- https://hub.docker.com/r/dorowu/ubuntu-desktop-lxde-vnc/
- https://blog.docker.com/2013/07/docker-desktop-your-desktop-over-ssh-running-inside-of-a-docker-container/
- Build a full Ubuntu desktop docker image
- http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
However, this still doesn't allow my Java application to execute GUI applications. As usual, I'm sure I'm missing something simple here.
How can I execute the Jetty container with access to the UI?