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 ubuntu:20.04
USER root
WORKDIR /home/app
RUN apt-get update
RUN apt-get install git --yes
# Install Google Chrome
RUN apt-get install wget
RUN apt-get install ./google-chrome*.deb --yes
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P /usr/bin/ && \ dpkg --unpack google-chrome-stable_current_amd64.deb && \ apt-get install -f -y,
#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/remote/index.js:248
-nodejs-1 | reject(Error(e.message))
-nodejs-1 | ^
-nodejs-1 |
-nodejs-1 | Error: Server terminated early with status 127
-nodejs-1 | at /LoadTesting/node_modules/selenium-webdriver/remote/index.js:248:24
-nodejs-1 | at processTicksAndRejections (node:internal/process/task_queues:96:5)
In my local windows environment, its working properly. As far as I know, I am installing chrome, chrome driver and selenium-webdriver.
What is missing?