代码之家  ›  专栏  ›  技术社区  ›  Saad

Docker py库中Docker容器等待/运行时间

  •  3
  • Saad  · 技术社区  · 9 年前

    我对python没有太多经验。。 我实现的功能是;

    for i in range(0,5):
        container = client.create_container(
                        image='syed/syedclients:helloworld',
                        stdin_open=True,
                        tty=True,
                        command='/bin/bash saad.sh /bin/sleep 180',
                        name=hello-1,                    
                        volumes=volumes,
                        host_config=host_config,
                        environment=['VARIABLE=xyz123'],
                        detach=True,
        )
        client.start(container)
    
    1 回复  |  直到 9 年前
        1
  •  2
  •   Sergiu    9 年前

    这与python无关,但更多的是与Docker有关。容器只执行您指定的操作,即:运行脚本并退出。因此,我建议您将sleep命令添加到“saad”。sh脚本