Python script for `docker run` command for Watchtower

Viewed 265

I want to run the following Docker container via a Python script.

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once

So far I've gotten this using the docker-py documents.

bindVolume = {'/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'mode': 'rw'}}

client.containers.run('containrrr/watchtower', name="watchtower", volumes = bindVolume, auto_remove=True

But how do I call --run-once?

1 Answers

try this :

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.

see this

Related