[why] default docker "-p port:port" will bind to all ips. - "-p 0.0.0.0:port:port" will also bind to all ips. - if exists ipv6 ip, it will bind to ipv6 address too. - if bind to ipv6 address, there will be tcp6 socket in TIME_WAIT no need bind to all ips.
Signed-off-by: Tong Qunfeng taxcom@tom.com --- container/scheduler/start | 9 +++++++-- container/taskqueue/start | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/container/scheduler/start b/container/scheduler/start index 305916e..d61616a 100755 --- a/container/scheduler/start +++ b/container/scheduler/start @@ -47,14 +47,19 @@ FLUENTD_PORT = defaults['FLUENTD_PORT'] || '24224' FLUENTD_SERVER_PORT = defaults['FLUENTD_SERVER_PORT'] || '24224' docker_rm "s001-alpine-#{SCHED_PORT}"
+bind_list = [] +[SCHED_HOST, '172.17.0.1'].uniq.each do |ip| + bind_list << '-p' + bind_list << "#{ip}:#{SCHED_PORT}:#{SCHED_PORT}" +end + cmd = %W[ docker run --restart=always --name s001-alpine-#{SCHED_PORT} -d -u 1090:1090 - -p #{SCHED_PORT}:#{SCHED_PORT} -] + env + %W[ +] + bind_list + env + %W[ -e CCI_REPOS=#{CCI_REPOS} -e LKP_SRC=#{DEFAULT_LKP} -e CCI_SRC=#{DEFAULT_CCI} diff --git a/container/taskqueue/start b/container/taskqueue/start index 4760b7d..bdd5e7c 100755 --- a/container/taskqueue/start +++ b/container/taskqueue/start @@ -16,19 +16,26 @@ defaults = relevant_defaults(names) env = docker_env(defaults)
service_port = defaults['TASKQUEUE_PORT'] || '3060' +service_host = defaults['TASKQUEUE_HOST'] || '172.17.0.1' service_name = 'taskqueue' service_image = "#{service_name}-alpine:v0.001-#{service_port}"
docker_rm "#{service_name}-#{service_port}"
+bind_list = [] +[service_host, '172.17.0.1'].uniq.each do |ip| + bind_list << '-p' + bind_list << "#{ip}:#{service_port}:#{service_port}" +end + cmd = %W[ docker run --name #{service_name}-#{service_port} --restart=always -d -u 1090:1090 - -p #{service_port}:#{service_port} ] +cmd += bind_list cmd += env cmd += %W[ -v /etc/localtime:/etc/localtime:ro