I am a novice in a docker container. I am trying to create a docker file that has npm, node js, chromedriver and selenium-chromedriver and run my javascript file. In my local , I run the script in the headless chrome browser.
Here is my docker file.
FROM node:17.2.0
USER root
WORKDIR /home/app
RUN apt-get update
RUN apt-get install git --yes
# Install Google Chrome
RUN apt-get install wget
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install ./google-chrome*.deb --yes
#FROM node:14.18.0
#FROM node:17.2.0
#USER root
ENV NODE_ENV=production
WORKDIR /LoadTesting
COPY ["/LoadTesting/package.json", "."]
RUN npm install
RUN npm ci
RUN npm install nodejs
RUN npm install mocha -g
RUN npm install chromedriver -g --unsafe-perm
RUN npm install selenium-webdriver
COPY /LoadTesting .
COPY /LoadTesting/test .
CMD ["node", "./test/script.js"]
following is my docker compose file
version: '3.7'
services:
k6:
image: "loadimpact/k6:0.32.0"
volumes:
- "./loadtesting:/scripts"
nodejs:
build:
context: ./
dockerfile: k6-nodejs-dockerfile
volumes:
- '.loadtesting:/loadtesting'
volumes:
grafana-storage:
prometheus-data:
external: true
Then I use following commands
docker compose build //no error
docker compose up k6 nodejs
Then I get following error.
/LoadTesting/node_modules/selenium-webdriver/lib/error.js:517
-nodejs-1 | let err = new ctor(data.message)
-nodejs-1 | ^
-nodejs-1 |
-nodejs-1 | WebDriverError: unknown error: Chrome failed to start: exited abnormally.
-nodejs-1 | (unknown error: DevToolsActivePort file doesn't exist)
-nodejs-1 | (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
-nodejs-1 | at Object.throwDecodedError (/LoadTesting/node_modules/selenium-webdriver/lib/error.js:517:15)
-nodejs-1 | at parseHttpResponse (/LoadTesting/node_modules/selenium-webdriver/lib/http.js:643:13)
-nodejs-1 | at Executor.execute (/LoadTesting/node_modules/selenium-webdriver/lib/http.js:569:28)
-nodejs-1 | at processTicksAndRejections (node:internal/process/task_queues:96:5) {
-nodejs-1 | remoteStacktrace: '#0 0x55d05197cee3 <unknown>\n' +
-nodejs-1 | '#1 0x55d05144a608 <unknown>\n' +
-nodejs-1 | '#2 0x55d05146d8ef <unknown>\n' +
-nodejs-1 | '#3 0x55d05146946f <unknown>\n' +
-nodejs-1 | '#4 0x55d0514a3f45 <unknown>\n' +
-nodejs-1 | '#5 0x55d05149e163 <unknown>\n' +
-nodejs-1 | '#6 0x55d051473bfc <unknown>\n' +
-nodejs-1 | '#7 0x55d051474c05 <unknown>\n' +
-nodejs-1 | '#8 0x55d0519aebaa <unknown>\n' +
-nodejs-1 | '#9 0x55d0519c4651 <unknown>\n' +
-nodejs-1 | '#10 0x55d0519afb05 <unknown>\n' +
-nodejs-1 | '#11 0x55d0519c5a68 <unknown>\n' +
-nodejs-1 | '#12 0x55d0519a405f <unknown>\n' +
-nodejs-1 | '#13 0x55d0519e0818 <unknown>\n' +
-nodejs-1 | '#14 0x55d0519e0998 <unknown>\n' +
-nodejs-1 | '#15 0x55d0519fbeed <unknown>\n' +
-nodejs-1 | '#16 0x7f46791e2ea7 <unknown>\n'
-nodejs-1 | }
-nodejs-1 |
What am I missing? simple google search says that my google chromer version and chromedriver version should match. How do I do it? I don't need a specific version as I run chrome in headless chrome browser in my script.
Please suggest.