0

I have created a Dockerfile that installs Xvfb and firefox with all the dependencies needed and I'm able to create a container with firefox launched on the DISPLAY=:1 of a Xserver.

When I try to launch another container, the second container is not able to launch a Xserver on DISPLAY=:1.

sudo docker logs docker_serv2
xvfb-run: error: Xvfb failed to start
No protocol specified

So I checked my processes with ps aux and I was suprised to see my X server listed on my host.

xxx 11343  1.9  0.6 240260 47620 ?        Sl   08:41   0:12 Xvfb :1 -screen 0 1280x720x24 -shmem -listen tcp -nolisten tcp -auth /home/xxx/.Xauthority
xxx 11350 18.7  4.2 2238084 326600 ?      Sl   08:41   2:07 /usr/lib/firefox/firefox

I use this command to create the Xserver and launch firefox on both containers :

xvfb-run -n 1 -f ~/.Xauthority --server-args='-screen 0 1280x720x24 -shmem -listen tcp' firefox

I understand that docker processes can be see on the host as it is not a VM, but I do not understand why the second container is not able to launch a X server on DISPLAY=:1 too, as the two containers are not linked.

Aren't they isolated from the host system ? I thought they would use their own minimalist environnement.

Here is my run.sh command :

docker run -d --rm \
--net=host \
-v /dev/uinput:/dev/uinput \
-v /dev/input:/dev/input \
-v /run/udev:/run/udev \
--name docker firefox

First I thought --net=host could be the source of my problem, but it only impacts the network configuration and I have the same issue without the option.

The others -v option are here because I'm also playing with some /dev/input instructions and are not important in this issue.

So, is it possible to launch two different containers launching two seperate X server on DISPLAY=:1 ?

Ryctus
  • 109
  • 2
  • 12

1 Answers1

0

Actually the issue came from the --net=host option.

I removed it from both run commands and I can launch two containers with X server on display1.

So the --net=host is not as isolated as I thought, and it does more than just match container network host.

Ryctus
  • 109
  • 2
  • 12
  • `--net host` turns off Docker's network isolation. It should be pretty unusual to actually need it. – David Maze Apr 19 '19 at 09:50
  • I realized it, it's just that I need to open some random port once my container is launched so it seemed to be a really good option, as it uses the host configuration. I've found no other solutions about opening specific port after the `docker run` command. – Ryctus Apr 19 '19 at 11:59
  • You should try to set things up so you don’t need to do anything after `docker run` at all; provide port-mapping options like `docker run -p` at startup time, and have the container set itself up. – David Maze Apr 19 '19 at 12:50
  • Yeah that's what I'm doing ;) Thanks for your help :) – Ryctus Apr 19 '19 at 14:21