gpt4 book ai didi

node.js - Docker 容器正在运行,但其进程已完成

转载 作者:太空宇宙 更新时间:2023-11-04 00:02:27 25 4
gpt4 key购买 nike

我在 Docker 容器中运行 TypeScript 应用程序。有时会发生应用程序完成但容器仍处于运行状态的情况。这怎么可能?我以为我忘记捕获被拒绝的 Promise 或忘记关闭流,但在这种情况下, docker top myContainer 会告诉我,主进程仍在运行,对吗?

Docker ps:

docker ps
5c63b442af79 filipxxx/v2x_communication "npm run start ether…" 2 hours ago Up 2 hours vehicle2

Docker 顶部:

docker top vehicle2
UID PID PPID C STIME

Docker 检查:

docker inspect vehicle2
[
{
"Id": "5c63b442af799b8ff3b83d7c53e1ccfd2a290d469b58b10970217aa987e963f9",
"Created": "2019-01-03T13:26:50.947651153Z",
"Path": "npm",
"Args": [
"run",
"start",
"ethereum",
"172.21.0.3:8545",
"run-producer",
"2",
"100",
"0xfb69fd63952d243fc235b91ff7bc49f9cd4a31f8"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 46799,
"ExitCode": 0,
"Error": "",
"StartedAt": "2019-01-03T13:33:52.860979672Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
...

令人惊讶的是,当运行docker exec -i Vehicle2 echo 'hello world'时,它返回我:无法在停止状态下执行:未知

下面是 dockerfile,我用来构建镜像。

FROM node:8

WORKDIR /v2x_communication
COPY . /v2x_communication

RUN npm install && npm run build

ENTRYPOINT ["npm", "run"]

即使我运行 docker stopvehicle2,它也会成功退出,但vehicle2仍然列在docker ps下,并且docker检查vehicle2仍然说它正在运行状态。

Docker 信息:

Containers: 50
Running: 48
Paused: 0
Stopped: 2
Images: 150
Server Version: 18.09.0
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: sah8xlcjnxbq13uofznqrjs6e
Is Manager: false
Node Address: 10.132.0.5
Manager Addresses:
10.132.0.2:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-1026-gcp
Operating System: Ubuntu 18.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 48
Total Memory: 94.41GiB
Name: vehicle-fleet-big-1
ID: OAVG:6QVR:EH3F:OYNO:ADC4:QDAN:R2AF:LSSV:2VSI:IJWJ:PJH2:LJVP
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support

最佳答案

要么您发现了错误,要么有什么东西使容器保持打开状态。我能找到的最接近的问题相当旧 #30927 。我将开始调查 dockerd 和操作系统日志,看看是否存在任何错误。对于 dockerd,它位于 systemd 环境的 journalctl -u docker 中。在操作系统上,/var/log 下的任何内容都可以很好地开始调试。我可以想象的潜在阻碍包括:

  • 失败的 shim 进程,可能是 runc 陷入僵尸状态
  • 挂载不会释放,某些东西可能正在尝试读取 docker 文件系统中的文件
  • 查询尚未退出的容器的命令,可能会拉取大量挂起等待管道/缓冲区清除的日志

如果您找不到任何内容,moby/moby 存储库中的问题可能是合适的,但如果没有任何错误日志指出原因或重现方法,则将很难修复。

关于node.js - Docker 容器正在运行,但其进程已完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54025289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com