构建 docker 镜像时 getaddrinfo() 线程无法启动

ABE*_*ABE 6 curl node.js docker

这是我的 Dockerfile

FROM linuxserver/code-server:latest
 
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
    apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)

我运行构建命令

docker build -t node-ide .
Run Code Online (Sandbox Code Playgroud)

在本地计算机(Windows 11)上运行正常。但是当我将其上传到 ubuntu 服务器并运行相同的命令时,出现错误

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM linuxserver/code-server:latest
 ---> 997b7b90cb65
Step 2/2 : RUN curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&    apt-get install -y nodejs
 ---> Running in d0ec2365c9d1
curl: (6) getaddrinfo() thread failed to start
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nodejs
The command '/bin/sh -c curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&    apt-get install -y nodejs' returned a non-zero code: 100
Run Code Online (Sandbox Code Playgroud)

为什么会发生这种情况?

小智 10

我帮助选择--security-opt seccomp=unconfined了 docker run

sudo docker run -it --security-opt seccomp=unconfined ubuntu
Run Code Online (Sandbox Code Playgroud)

对于 docker-compose.yml

services:
  example:
    build: .
    security_opt:
      - seccomp:unconfined
Run Code Online (Sandbox Code Playgroud)


Fre*_*ndt 9

这很可能是由于glibcdocker 映像中使用的库不匹配,期望允许系统clone(3)调用,而您的 Docker 引擎(在主机上)不允许它。

https://github.com/adoptium/containers/issues/215#issuecomment-1142046045


ABE*_*ABE 0

根据@yong的评论,我降级了,现在它的工作原理如下:

FROM linuxserver/code-server:4.4.0-ls125
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
    sudo apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)