Skip to content

Commit e2c1c9c

Browse files
authored
Merge pull request #2332 from docker/use_proxy_config_default
Change use_config_proxy default value to True to match CLI behavior
2 parents 836194c + 7f56f70 commit e2c1c9c

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

docker/api/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
2020
decode=False, buildargs=None, gzip=False, shmsize=None,
2121
labels=None, cache_from=None, target=None, network_mode=None,
2222
squash=None, extra_hosts=None, platform=None, isolation=None,
23-
use_config_proxy=False):
23+
use_config_proxy=True):
2424
"""
2525
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
2626
needs to be set. ``path`` can be a local path (to a directory

docker/api/container.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import six
21
from datetime import datetime
32

3+
import six
4+
45
from .. import errors
56
from .. import utils
67
from ..constants import DEFAULT_DATA_CHUNK_SIZE
7-
from ..types import (
8-
CancellableStream, ContainerConfig, EndpointConfig, HostConfig,
9-
NetworkingConfig
10-
)
8+
from ..types import CancellableStream
9+
from ..types import ContainerConfig
10+
from ..types import EndpointConfig
11+
from ..types import HostConfig
12+
from ..types import NetworkingConfig
1113

1214

1315
class ContainerApiMixin(object):
@@ -222,7 +224,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
222224
mac_address=None, labels=None, stop_signal=None,
223225
networking_config=None, healthcheck=None,
224226
stop_timeout=None, runtime=None,
225-
use_config_proxy=False):
227+
use_config_proxy=True):
226228
"""
227229
Creates a container. Parameters are similar to those for the ``docker
228230
run`` command except it doesn't support the attach options (``-a``).
@@ -414,7 +416,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
414416
if use_config_proxy:
415417
environment = self._proxy_configs.inject_proxy_environment(
416418
environment
417-
)
419+
) or None
418420

419421
config = self.create_container_config(
420422
image, command, hostname, user, detach, stdin_open, tty,

tests/integration/api_exec_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def test_execute_command_with_proxy_env(self):
1717

1818
container = self.client.create_container(
1919
BUSYBOX, 'cat', detach=True, stdin_open=True,
20-
use_config_proxy=True,
2120
)
2221
self.client.start(container)
2322
self.tmp_containers.append(container)

tests/integration/models_containers_test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
import tempfile
33
import threading
44

5-
import docker
65
import pytest
7-
from .base import BaseIntegrationTest, TEST_API_VERSION
8-
from ..helpers import random_name, requires_api_version
6+
7+
import docker
8+
from ..helpers import random_name
9+
from ..helpers import requires_api_version
10+
from .base import BaseIntegrationTest
11+
from .base import TEST_API_VERSION
912

1013

1114
class ContainerCollectionTest(BaseIntegrationTest):
@@ -174,9 +177,7 @@ def test_run_with_proxy_config(self):
174177
ftp='sakuya.jp:4967'
175178
)
176179

177-
out = client.containers.run(
178-
'alpine', 'sh -c "env"', use_config_proxy=True
179-
)
180+
out = client.containers.run('alpine', 'sh -c "env"')
180181

181182
assert b'FTP_PROXY=sakuya.jp:4967\n' in out
182183
assert b'ftp_proxy=sakuya.jp:4967\n' in out

0 commit comments

Comments
 (0)