10

In order to examine selenium tests running inside a docker image I am trying to set up a VNC to verify what is going on during the tests.

I am following the suggestions made here and created a new docker image with the following additional lines in Dockerfile:

RUN     apt-get install -y x11vnc 
RUN     mkdir ~/.vnc
RUN     x11vnc -storepasswd 1234 ~/.vnc/passwd

Then I started the docker image with the following command:

docker run -p 5900 --rm -it --entrypoint /bin/bash selenium-tests

and started krdc as my VNC viewer. So now what?

I do not see my docker image in krdc. Maybe I am missing something? Do I have to start the vnc code inside docker explicitly? Do I need to pass additional arguments to the docker command?

  • docker: 1.13.1
  • ubuntu: 16.4.03
  • krdc: 4.14.16
Alex
  • 41,580
  • 88
  • 260
  • 469
  • Hey, if you only want to run Selenium, maybe you can use this image: https://hub.docker.com/r/selenium/standalone-chrome – Lai32290 Mar 10 '19 at 12:11

1 Answers1

16

There are two issues in the question that prevent you from the goal you want to achieve:

1. X server is missed in the image.

2. VNC server should be started in a container.

The additional part of Dockerfile is:

RUN apt-get install -y x11vnc xvfb 
RUN mkdir ~/.vnc
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

where entrypoint.sh is:

#!/bin/bash
x11vnc -forever -usepw -create &
/bin/bash

Now we can start a container using the following command:

docker run --rm -ti -p 5900:5900 <image_name_or_id>

and access it via vncviewer from the same host where container is started:

vncviewer localhost:5900
nickgryg
  • 25,567
  • 5
  • 77
  • 79
  • 1
    Don't you need to set the executable bit on entrypoint.sh? – Calab Jan 15 '21 at 16:50
  • 1
    Yes, executable bit should be set on `entrypoint.sh`. – nickgryg Jan 18 '21 at 01:51
  • 2
    I don't see why a shell script is needed here... seems like unnecessary over-enginerring because of < insert reason > Just make it ```ENTRYPOINT x11vnc -forever -usepw -create & /bin/bash``` Keep is simple – Branden Feb 22 '22 at 15:42