在Ubuntu 18.04服务器上,docker运行的是10个不同的容器。
这些容器是使用python docker(https://docker-py.readthedocs.io/en/stable/api.html#module-docker.api.container)即时创建或删除的(每天约有100个docker)。
但是docker服务在运行1天或8天后会随机崩溃。
以下是我的docker服务崩溃后的日志:
-docker logs docker1
Error response from daemon: can not get logs from container which is dead or marked for removal
-docker logs docker2
Error response from daemon: configured logging driver does not support reading
-sudo journalctl -r -u docker
level=info msg="Container 9a4b940f299b failed to exit within 10 seconds of kill - trying direct SIGKILL"
level=error msg="Handler for GET /v1.40/containers/e369e13c11339d0365fd467c1208a2a490821c37320b0f0c8778f46a87f4aaa4/logs returned error: configured logging driver does not support reading"
-systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/docker.service.d
└─docker.conf
Active: active (running) since Tue 2020-05-05 08:32:58 UTC; 13h ago
Docs: https://docs.docker.com
Main PID: 2207 (dockerd)
Tasks: 62
CGroup: /system.slice/docker.service
└─2207 /usr/bin/dockerd
level=error msg="Handler for POST /v1.40/exec/d61a8160aa3bb9bca58fbbd10b781e2dde920006e7ed09ad5838710f00d23d2a/resize returned error: timeout waiting for exec session ready"
level=error msg="Handler for GET /v1.40/containers/e369e13c11339d0365fd467c1208a2a490821c37320b0f0c8778f46a87f4aaa4/logs returned error: configured logging driver does not support reading"
level=info msg="Container 9a4b940f299b failed to exit within 10 seconds of kill - trying direct SIGKILL"
-我无法创建或删除任何Docker容器,因此我尝试“服务docker restart”,但无法正常工作:
-systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/docker.service.d
└─docker.conf
Active: activating (start) since Tue 2020-05-05 22:24:51 UTC; 45min ago
Docs: https://docs.docker.com
Main PID: 20907 (dockerd)
Tasks: 23
CGroup: /system.slice/docker.service
└─20907 /usr/bin/dockerd
level=info msg="Starting up"
level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve/resolv.conf"
level=info msg="parsed scheme: \"unix\"" module=grpc
level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] <nil>}" module=grpc
level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
level=info msg="parsed scheme: \"unix\"" module=grpc
level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] <nil>}" module=grpc
level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
-journalctl -r -u docker:
level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] <nil>}" module=grpc
level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
level=info msg="parsed scheme: \"unix\"" module=grpc
level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] <nil>}" module=grpc
level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
level=info msg="parsed scheme: \"unix\"" module=grpc
level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve/resolv.conf"
level=info msg="Starting up"
Starting Docker Application Container Engine...
Stopped Docker Application Container Engine.
我必须重新启动服务器才能最终使我的Docker服务再次运行。
那么您是否知道发生了什么?
如果需要,我可以提供更多日志。
谢谢。
PS:
Docker -v:Docker版本19.03.8,构建afacb8b7f0。
副作用df -h在我的服务器上不起作用。
编辑: 我先用
停止了我的docker容器stop(container, timeout=None)
https://docker-py.readthedocs.io/en/stable/api.html#docker.api.container.ContainerApiMixin.stop
然后我用
将其删除remove_container(container, v=False, link=False, force=False)