我在docker容器中运行我的打字稿应用程序。有时会发生应用程序完成的情况,但是容器仍处于运行状态。这怎么可能呢?我当时以为我忘记了被拒绝的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'
时,它返回了我:cannot exec in a stopped state: unknown
。
下面是dockerfile,我用来构建映像。
FROM node:8
WORKDIR /v2x_communication
COPY . /v2x_communication
RUN npm install && npm run build
ENTRYPOINT ["npm", "run"]
即使我运行docker stop vehicle2,它也成功退出,但是vehicle2仍列在docker ps
下,并且docker inspect 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
答案 0 :(得分:1)
要么您发现了一个错误,要么是某种原因使容器保持打开状态。我能找到的最接近的问题是较旧的#30927。我将开始研究dockerd和OS日志,以查看是否可以找到任何错误。对于dockerd,在系统环境中位于journalctl -u docker
中。在OS上,/ var / log下的任何内容都可以开始调试。我能想象到的潜在障碍包括:
如果找不到任何东西,则在Moby / Moby回购中出现问题可能是适当的,但如果没有任何错误记录,指出原因或复制方法,将很难解决。
>