Installing Java on a docker image for Selenium/Nightwatch e2e testing


I’m trying to get my Nightwatch e2e tests to run (CircleCI 2.0). I’m not able to figure out how to get Java installed to run Selenium without having a custom Docker image.

An error occurred while trying to start Selenium. Check if JAVA is installed on your machine.

Additionally, for some strange reason, the build is reported as a Success.

Any advice on how to get this going?


To answer my own question - Custom docker images seem to be the way to do it. Here’s what I use to get nightwatch up and running. Make sure to use the browsers tag on the circleci images - or you’ll run into crazy problems with Chrome and Selenium.

FROM circleci/node:7.10.0-browsers
RUN echo "deb jessie-backports main" | sudo tee --append /etc/apt/sources.list
RUN sudo apt-get update
RUN sudo apt-get install -t jessie-backports openjdk-8-jdk


Hello, I have the same problem, but I cant solve it.

Im using v2 with - image: circleci/node:latest
This is my result when trying to run e2e tests:


You need to create your own custom image with Java installed. This image will save you the trouble:


Hello, thanks. Can you tell more about how to set that custom image? Im newbie with docker and circleci.

  - run: sudo su -c 'echo "deb jessie-backports main" >> /etc/apt/sources.list'
  - run: |
      sudo rm -rf /var/lib/apt/lists/*
      sudo apt-get update
      sudo apt install -t jessie-backports  openjdk-8-jre-headless ca-certificates-java

Doing this on a circleci/node:6.11.1-browsers image and I can run my nightwatch tests just fine with it.


Hi, thanks for your help @ben-watt . I’m still having problems.
This is my config.yml file:

# Javascript Node CircleCI 2.0 configuration file
# Check for more details
version: 2
      # specify the version you desire here
      - image: circleci/node:6.11.1-browsers

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at
      # - image: circleci/mongo:3.4.4

    working_directory: ~/repo

      - checkout

      # Download and cache dependencies
      - restore_cache:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: npm install

      - save_cache:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: sudo su -c 'echo "deb jessie-backports main" >> /etc/apt/sources.list'
      - run: sudo rm -rf /var/lib/apt/lists/*
      - run: sudo apt-get update
      - run: sudo apt install -t jessie-backports  openjdk-8-jre-headless ca-certificates-java

      # run tests!
      - run: npm test

Can you tell me what is wrong? Thanks!!


Hey @baumannzone, I’m working on an article which covers all of these steps in detail. I’ll post the link here in a couple of hours when I’m done.


Nice to hear it. I’ll wait. Thank you.


Hello, @karthikiyengar did you get something? I’m excited!


Hi @baumannzone - You can find it here:

Do take some time out to understand how Docker and the CircleCI config.yml works. For now, you can use the custom image that I’ve built here:

Modify your Docker config to this

      - image: karthikiyengar/node-nightwatch:0.0.1


Wow, your docker image is working very well for me! Thanks.:blush:


Glad it was helpful. Cheers.


What @ben-watt posted worked for me. My image was circleci/node:7.10.1


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.