Run a NOT headless chrome on a docker container
Use Xvfb. This will allow you to use Chrome with GUI.
The idea is simple: you use virtual desktop. Configuring multiple desktops / displays on a standalone VM took some efforts. With Docker it is simple.
Some examples:
http://www.mattzeunert.com/2018/07/21/running-headful-chrome-on-ubuntu-server.html
https://medium.com/dot-debug/running-chrome-in-a-docker-container-a55e7f4da4a8
Another way (described here by Nils De Moor) is to let the docker container connect to your local machine's X server.
Say your ip address is 192.168.0.2
.
You can set up a tunnel to you X display on i.e. port 6010, (which corresponds to display 192.168.0.2:10
) with socat
. For security, the range
argument asks socat
to only accept connections from your machine's IP address.
socat TCP-LISTEN:6010,reuseaddr,fork,range=192.168.0.2/32 UNIX-CLIENT:\"$DISPLAY\" &
Now you can set the DISPLAY
variable inside the docker container with -e
when you start it.
docker run -e DISPLAY=192.168.0.2:10 gns3/xeyes
In the case of chrome
there are some more complications, described in the linked post, because chrome requires some more privileges (i.e. add --privileged
)