Score:0

docker - nodejs - selenium-webdriver - Error: Server terminated early with status 127

us flag
Jay

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?

Score:0
in flag

You can't use two FROM lines like that. Everything before the second FROM line will not be available after that, it will start a new image.

Quote from the FROM documentation:

Each FROM instruction clears any state created by previous instructions.

You can copy files from the previous stage over to the second one, as described in the multi-stage build documentation:

FROM golang:1.16 AS builder
# do your stuff
FROM alpine:latest
COPY --from=builder /go/src/github.com/alexellis/href-counter/app ./
# do more stuff

Alternative: The node image is based on a debian image. You should be able to install what you need directly in that image.

in flag
@jay please don't edit answers of other people like that. You can comment on your own question to request clarifications, and you can edit your own question to provide more information. But don't edit your question in a way that would render answers completely invalid. Sometimes it's better to ask a new question if a follow up problem arises.
Jay avatar
us flag
Jay
I am sorry. That was a mistake
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.