Currently, I am running Selenium Test scripts written in PHP and running them through Jenkins using Docker Compose. You can do the same as without problems with Xvfb itself.
To run Selenium tests using browsers without a browser inside the docker container and bind it to your application using docker, you can simply use a predefined stand-alone server.
https://github.com/SeleniumHQ/docker-selenium
I am currently using a standalone Chrome image.
Here is what your docker essay should look like:
version: '3' services: your-app: build: context: . dockerfile: Dockerfile your_selenium_application: build: context: . dockerfile: Dockerfile.selenium.test depends_on: - chrome-server - your-app chrome-server: image: selenium/standalone-chrome:3.4.0-einsteinium
When docker-compose starts, it will deploy your application, a selenium environment that will interact with your application, and a stand-alone server that will provide you with your dumb browser. Since they are interconnected, inside the selenium code, you can make your test requests to the host through your application: for example, 80. Your browser without a browser will be chrome-server: 4444 / wd / hub, which is the default address.
All this can be done inside Jenkins using only one command on your command line inside your Jenkins Job. docker-compose will also allow you to easily run tests on your local machine, and the results should be identical.
Serey source share