简体   繁体   中英

Docker container stuck running from Python SDK

I am following the example in Docker SDK for Python: https://docker-py.readthedocs.io/en/stable/containers.html . But the container seems to be stuck after running and do not output anything:

Python 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> client = docker.from_env()
>>> client.containers.run("ubuntu", "echo hello world")

Does anyone have the same issue?

EDIT 2:
I don't know why the first time it did not progress even after strace showing a download image complete message. I killed the process and retried, this time it worked. I am running everything on a virtual machine. It seems there are some related issues with docker itself, don't think this could be an SDK issue. See for example this . The second time I also had disabled the host antivirus (Win7 security essentials, but I'm not sure it did the trick).
EDIT:
Actually it is taking too long to complete also in my case. I guess it is because the first time the python process has to download the ubuntu image which is around 180MB in size.

Original answer:
Open another session and find the process id using the ps command. Then do strace -p <pid> . You'll see the that actually the process is doing something:

recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 195
recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 195
recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 195
recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 195
recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 195
recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 195
recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 195
recvfrom(4, "bd\r\n{\"status\":\"Downloading\",\"pro"..., 8192, 0, NULL, NULL) = 19

Just wait until it completes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM