From a083494b6e7dc955599cd57d5eaec8433c8df362 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Wed, 12 Apr 2017 23:59:52 +0000 Subject: [PATCH] Allow host of docker daemon to be configurable An immediate use case is to enable attaching to containers that are behind the proxy. In this case, the ip address of docker daemon won't be reachable from outside thus attaching is impossible. With this config, cloud admins can set a reachable ip address for external access of docker daemon. Change-Id: If4981154139c98ad4a8373744d29938214991ca6 --- zun/conf/docker.py | 8 +++++++- zun/container/docker/driver.py | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/zun/conf/docker.py b/zun/conf/docker.py index fdd72ee67..578777830 100644 --- a/zun/conf/docker.py +++ b/zun/conf/docker.py @@ -11,6 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import socket + from oslo_config import cfg docker_group = cfg.OptGroup(name='docker', @@ -40,9 +42,13 @@ docker_opts = [ cfg.StrOpt('key_file', help='Location of TLS private key file for ' 'securing docker api requests (tlskey).'), + cfg.StrOpt('docker_remote_api_host', + default=socket.gethostname(), + sample_default='localhost', + help='Defines the remote api host for the docker daemon.'), cfg.StrOpt('docker_remote_api_port', default='2375', - help='Defines the remote api port for the container.'), + help='Defines the remote api port for the docker daemon.'), ] ALL_OPTS = (docker_opts) diff --git a/zun/container/docker/driver.py b/zun/container/docker/driver.py index 6db88ed35..6874a6d3b 100644 --- a/zun/container/docker/driver.py +++ b/zun/container/docker/driver.py @@ -355,8 +355,9 @@ class DockerDriver(driver.ContainerDriver): @check_container_id def get_websocket_url(self, container): version = CONF.docker.docker_remote_api_version + remote_api_host = CONF.docker.docker_remote_api_host remote_api_port = CONF.docker.docker_remote_api_port - url = "ws://" + container.host + ":" + remote_api_port + \ + url = "ws://" + remote_api_host + ":" + remote_api_port + \ "/v" + version + "/containers/" + container.container_id \ + ATTACH_FLAG return url