Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Laravel Dusk running within (lara)dock


Working solution for laradock

  • spin up the selenium image (selenium/standalone-chrome) as included with laradock
  • in .env.dusk.local set APP_URL=http://nginx to point to the docker nginx image
  • in tests\DuskTestCase.php replace the line 'http://localhost:9515', DesiredCapabilities::chrome() with 'http://selenium:4444/wd/hub', DesiredCapabilities::chrome()
  • run php artisan dusk
  • ...

=========================================================================================== Directions below this point were premature workarounds.


  • xvfb-run / xvfb are not killed after running dusk


  • Build chrome + xvfb into a container:
RUN apt-get install -y wget && \
    wget -q -O - |  apt-key add - && \
    sh -c 'echo "deb [arch=amd64] stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \
    apt-get update && apt-get install -y google-chrome-stable && \
    apt-get install -y xvfb
  • (re)build your container and start it

  • overload the method buildChromeProcess in the Laravel\Dusk\SupportsChrome trait by adding the following code to your tests/DuskTestCase.php:

     * Build the process to run the Chromedriver.
     * @return \Symfony\Component\Process\Process
    protected static function buildChromeProcess()
        return (new ProcessBuilder())
  • Run php artisan dusk

This comment has been minimized.

Copy link

@ELD ELD commented May 19, 2017

I get a 404 Not Found when I try to run dusk using your instructions. Any idea why?


This comment has been minimized.

Copy link

@tboztuna tboztuna commented Jan 15, 2020

selenium can not connect to nginx container. It says 'nginx's server IP address could not be found.' .
Anyone had this problem before?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment