0

I am trying to run a GUI from a CentOS container. I tried to follow this example. This is my Dockerfile:

#!/bin/bash
FROM centos:7
#RUN yum install -y firefox dbus dbus-x11
RUN yum install -y firefox 
# Replace 0 with your user / group id
RUN export uid=1000 gid=100
RUN mkdir -p /home/developer
RUN echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd
RUN echo "developer:x:${uid}:" >> /etc/group
RUN echo "developer ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN chmod 0440 /etc/sudoers
RUN chown ${uid}:${gid} -R /home/developer
#RUN dbus-uuidgen > /var/lib/dbus/machine-id

#RUN export $(dbus-launch)

USER developer
ENV HOME /home/developer
CMD /usr/bin/firefox

I then run the following commands in my terminal.

   docker run -ti --rm \
       -e DISPLAY=$DISPLAY \
       -v /tmp/.X11-unix:/tmp/.X11-unix \
       firefox

    process 8: D-Bus library appears to be incorrectly set up; failed to read machine uuid: UUID file '/etc/machine-id' should contain a hex string of length 32, not length 0, with no other text
    See the manual page for dbus-uuidgen to correct this issue.
      D-Bus not built with -rdynamic so unable to print a backtrace
    Running without a11y support!
    No protocol specified
    Error: cannot open display: :0.0

I have tried this solution, where I add the following lines to my Dockerfile,

# apt-get install -y dbus
# dbus-uuidgen > /var/lib/dbus/machine-id

But that didn't fix the problem. Any ideas?

Edit: My host OS is Arch Linux. And I really am trying to run this example in CentOs.I don't really need a container that runs a Firefox GUI. I was just trying to get the simplest example of a GUI running in a CentOS container running, and I failed at that.

shadeless
  • 95
  • 2
  • 8

1 Answers1

0

Problem is with your DockerFile, your base image is Centos and rest of command you running for Ubuntu.

FROM ubuntu

RUN apt-get update && apt-get install -y firefox

# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
    mkdir -p /home/developer && \
    echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
    echo "developer:x:${uid}:" >> /etc/group && \
    echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer && \
    chown ${uid}:${gid} -R /home/developer

USER developer
ENV HOME /home/developer
CMD /usr/bin/firefox

You Run command will be

docker run -ti --rm  -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix firefox

The above image is tested in Ubuntu 18.04 and working fine.

For window try like this

docker run -ti --rm -e DISPLAY=$DISPLAY firefox

You check the above image on docker registry.

docker pull adilm7177/firefox
Adiii
  • 54,482
  • 7
  • 145
  • 148
  • 1
    Do you know how I can change my Dockerfile to work for CentOs7? I am really trying to run another GUI program that is only supported in RedHat and CentOs. – shadeless Jan 13 '19 at 03:17
  • You can try ubuntu as well but you did not mentioned that i question that you really intersted in centos – Adiii Jan 13 '19 at 03:28
  • I really do need CentOs because the software (ANSYS) I am trying to run is supported on it. But I did try your Ubuntu example and I ran into this error: No protocol specified Error: Can't open display: :0 So I don't know. I'll keep looking for answers. For reference, my host OS is Arch Linux and my Docker version is 1:18.09.1-1. – shadeless Jan 15 '19 at 03:28
  • 1
    https://stackoverflow.com/questions/28392949/running-chromium-inside-docker-gtk-cannot-open-display-0 – Adiii Jan 15 '19 at 03:32