[docker-wait-any] Use APIClient instead of Client according to API update

due to the upgrade from docker-py (1.6.0) to docker (4.1.0)
This commit is contained in:
Stephen Sun 2020-03-15 16:15:08 +08:00 committed by Guohan Lu
parent f1cc577c75
commit aec51c8aaf

View File

@ -11,13 +11,13 @@
stopped running. Here, we spawn multiple threads and wait on one stopped running. Here, we spawn multiple threads and wait on one
container per thread. If any of the threads exit, the entire container per thread. If any of the threads exit, the entire
application will exit. application will exit.
NOTE: This script is written against docker-py version 1.6.0. Newer NOTE: This script is written against docker Python package 4.1.0. Newer
versions of docker-py have a different API. versions of docker may have a different API.
""" """
import sys import sys
import threading import threading
from docker import Client from docker import APIClient
# Instantiate a global event to share among our threads # Instantiate a global event to share among our threads
g_thread_exit_event = threading.Event() g_thread_exit_event = threading.Event()
@ -40,7 +40,7 @@ def wait_for_container(docker_client, container_name):
def main(): def main():
thread_list = [] thread_list = []
docker_client = Client(base_url='unix://var/run/docker.sock') docker_client = APIClient(base_url='unix://var/run/docker.sock')
# Ensure we were passed at least one argument # Ensure we were passed at least one argument
if len(sys.argv) < 2: if len(sys.argv) < 2: