繁体   English   中英

无法使用我刚刚构建的 Docker Python API 运行映像

[英]Can't run image with Docker Python API that I just built

我创建了许多自动生成的Dockerfile ,然后使用Docker SDK for Python将它们构建到图像中。

这些图像已被命名为

REPOSITORY                                              TAG     IMAGE ID       CREATED         SIZE
octomy-static-qt.linux.debian.bullseye.x86.6.2.0.static latest  def54a505ab5   22 hours ago    1.57GB

但是当我想运行图像时,似乎我无法做到。 我总是收到docker.errors.NotFound错误。 I specify octomy-static-qt.linux.debian.bullseye.x86.6.2.0.static as the image name. 实际代码如下所示:

try:
    output=client.containers.run(
        image=dotname
        , command=fingerprint_script
        , auto_remove=True
        , remove=True
        , name=f"fingerprint-{dotname}"
        )
    print(f"FINGERPRINT OUTPUT FROM {dotname} IS:")
    print(output)
except docker.errors.NotFound as nf:
    logger.warning(f"Image for '{dotname}' not found while doing fingerprint, skipping...")
    pprint.pprint(config)

其中dotname包含上面列出的全名。

但是,当我像这样运行 docker 命令时

docker run octomy-static-qt.linux.debian.bullseye.x86.6.2.0.static

图像似乎工作正常。 我无法弄清楚我在这里做错了什么。

我尝试用“alpine”替换我的图像名称,然后它似乎运行良好。 所以这让我相信我的图像名称在某种程度上存在固有的错误。

所以我的问题是,为什么在这种情况下我的图像不能作为容器运行

需要告诉docker run命令要运行哪个命令

尝试

docker run -it octomy-static-qt.linux.debian.bullseye.x86.6.2.0.static /bin/sh

这应该在 docker 容器中启动一个交互式 shell 。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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