如何使用交互式控制台启动已退出的 docker 容器?

如何使用交互式控制台启动已退出的 docker 容器?

我认真尝试了在网络上找到的每一个命令来打开退出的控制台并与其交互,但没有一个起作用。我正在尝试恢复我之前编译内核的 docker 容器。请告诉我我做错了什么。

这是我尝试过的:

root@M14EBR:~# docker exec -it a5416008966b /bin/bash
Error response from daemon: Container a5416008966b9cbe24cd91b529541536b5342bfe5c49052d12983771c569f7a5 is not running.

root@M14EBR:~# docker start -a -i `docker ps -q -l`
"docker ps -a" still shows all containers exited

root@M14EBR:~# docker run -i a5416008966b /bin/bash
Unable to find image 'a5416008966b:latest' locally
docker: Error response from daemon: pull access denied for a5416008966b,repository does not exist or may require 'docker login'.
See 'docker run --help'.


root@M14EBR:~# docker start ee86103a86d2
ee86103a86d2
root@M14EBR:~# docker ps -a
ee86103a86d2        debian              "/bin/bash"         13 hours ago        Exited (0) 5 seconds ago

答案1

您需要查看此容器报告的启动日志内容:

docker logs <container id>

其中<container id>显示在docker ps -a.

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                          PORTS               NAMES
4c3ae992631c        sysdig/sysdig       "/docker-entrypoin..."   About a minute ago   Exited (0) About a minute ago                       sysdig

$ docker logs 4c3ae992631c
* Setting up /usr/src links from host
* Unloading sysdig-probe, if present
rmmod: ERROR: Module sysdig_probe is not currently loaded
* Running dkms install for sysdig
Error! echo
Your kernel headers for kernel 3.10.0-693.21.1.el7.x86_64 cannot be found at
/lib/modules/3.10.0-693.21.1.el7.x86_64/build or /lib/modules/3.10.0-693.21.1.el7.x86_64/source.
* Trying to load a system sysdig-probe, if present
* Trying to find precompiled sysdig-probe for 3.10.0-693.21.1.el7.x86_64
Found kernel config at /host/boot/config-3.10.0-693.21.1.el7.x86_64
* Trying to download precompiled module from https://s3.amazonaws.com/download.draios.com/stable/sysdig-probe-binaries/sysdig-probe-0.21.0-x86_64-3.10.0-693.21.1.el7.x86_64-9df7f67292ca873f1d3b016b35438cfb.ko
Download failed, consider compiling your own sysdig-probe and loading it or getting in touch with the sysdig community
root@4c3ae992631c:/# exit
exit

由于该容器已“退出”,您可以像这样重新启动它:

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES
4c3ae992631c        sysdig/sysdig       "/docker-entrypoin..."   3 minutes ago       Exited (0) 3 minutes ago                       sysdig

$ docker start 4c3ae992631c
4c3ae992631c

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
4c3ae992631c        sysdig/sysdig       "/docker-entrypoin..."   3 minutes ago       Up 4 seconds                            sysdig

注册表登录

根据您对问题的更新,此消息似乎是您的问题:

docker:来自守护进程的错误响应:a5416008966b 的拉取访问被拒绝,存储库不存在或可能需要“docker 登录”。请参阅“docker run --help”。

因此,要么注册表要求您使用docker login注册表/集线器帐户,要么您的容器所基于的映像在 Docker 注册表中不再可用。

相关内容