Repository provide configuration example of Selenium with docker images
What you need to do:
- Install docker (https://docs.docker.com/release-notes/docker-ce/#17031-ce-2017-03-27)
- Install VNC Viewer (https://www.realvnc.com/en/connect/download/viewer/)
- Navigate to the folder where docker-compose.yml file and execute from command line command: docker-compose up
- Wait until all necessary images are downloaded :)
- From command line execude command: docker ps -a (see created containers)
- Open VNC Viewer and add path to your container (VNC allow us to see what happen in our tests)

- Don't forget to add some changes in your code see :
if (driver == null) {
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setBrowserName("firefox");
capabilities.setPlatform(Platform.LINUX);
try {
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
return driver;