我在Docker容器中运行typescript应用程序。有时,应用程序完成,但容器仍处于运行状态。这怎么可能呢?我在想我忘记了接受一个被拒绝的承诺或者忘记了关闭一条小溪,但是在那种情况下,
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"]
即使我运行码头停靠车2,它成功退出,但车辆2仍然列在
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