我想通过 Python 脚本运行以下 Docker 容器。
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once
到目前为止,我已经使用 docker-py 得到了这个文档。
bindVolume = {'/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'mode': 'rw'}}
client.containers.run('containrrr/watchtower', name="watchtower", volumes = bindVolume, auto_remove=True
但是如何调用--run-once呢?
请您参考如下方法:
试试这个:
client.containers.run('containrrr/watchtower',command=["--run-once"], name="watchtower", volumes = bindVolume, auto_remove=True)
command (str or list) – The command to run in the container.
参见 this
