Instantiate APIClient using defined envars e.g. DOCKER_HOST

This commit is contained in:
Sam 2018-03-07 08:42:04 -05:00
parent 8eb165385f
commit fc72a150d8
2 changed files with 8 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import docker.errors
import requests.exceptions
from docker_custodian.args import timedelta_type
from docker.utils import kwargs_from_env
log = logging.getLogger(__name__)
@ -66,7 +67,9 @@ def main():
stream=sys.stdout)
opts = get_opts()
client = docker.APIClient(version='auto', timeout=opts.timeout)
client = docker.APIClient(version='auto',
timeout=opts.timeout,
**kwargs_from_env())
matcher = build_container_matcher(opts.prefix)
stop_containers(client, opts.max_run_time, matcher, opts.dry_run)

View File

@ -14,6 +14,7 @@ import docker.errors
import requests.exceptions
from docker_custodian.args import timedelta_type
from docker.utils import kwargs_from_env
log = logging.getLogger(__name__)
@ -220,7 +221,9 @@ def main():
stream=sys.stdout)
args = get_args()
client = docker.APIClient(version='auto', timeout=args.timeout)
client = docker.APIClient(version='auto',
timeout=args.timeout,
**kwargs_from_env())
if args.max_container_age:
cleanup_containers(client, args.max_container_age, args.dry_run)