首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >docker - nodejs - selenium-webdriver :服务器以状态127提前终止

docker - nodejs - selenium-webdriver :服务器以状态127提前终止
EN

Server Fault用户
提问于 2021-12-03 12:21:03
回答 1查看 1.6K关注 0票数 0

我是码头集装箱的新手。我正在尝试创建一个具有npm、节点js、chromedriver和selenium-chromedriver的docker文件,并运行我的javascript文件。在本地,我在无头铬浏览器中运行脚本。

这是我的码头文件。

代码语言:javascript
复制
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"]

以下是我的码头撰写文件

代码语言:javascript
复制
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

然后我使用以下命令

代码语言:javascript
复制
docker compose build //no error
docker compose up k6 nodejs

那么我就得到了跟随错误。

代码语言:javascript
复制
| /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)

在我的本地windows环境中,它正常工作。据我所知,我正在安装铬,铬驱动程序和硒-网络驱动程序.

少了什么?

EN

回答 1

Server Fault用户

回答已采纳

发布于 2021-12-03 12:26:49

您不能使用这样的两行FROM。在第二个FROM行之前的所有内容都将在此之后不可用,它将启动一个新的映像。

引用FROM文档的话:

每个FROM指令清除先前指令创建的任何状态。

您可以将文件从上一阶段复制到第二阶段,如多阶段构建文档中所述:

代码语言:javascript
复制
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

替代方案:节点映像基于debian映像。您应该能够直接在映像中安装所需的内容。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1085307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档