From 50bcf47873959458229be209231a6d90587e8900 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 11 Nov 2016 14:19:41 +0100 Subject: [PATCH] Add support for extra_hosts in composefile v3 Signed-off-by: Vincent Demeester Upstream-commit: f32869d956eb175f88fd0b16992d2377d8eae79c Component: engine --- components/engine/cli/command/stack/deploy.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/engine/cli/command/stack/deploy.go b/components/engine/cli/command/stack/deploy.go index 94ef6bac2c..9996f128b3 100644 --- a/components/engine/cli/command/stack/deploy.go +++ b/components/engine/cli/command/stack/deploy.go @@ -498,6 +498,7 @@ func convertService( Command: service.Entrypoint, Args: service.Command, Hostname: service.Hostname, + Hosts: convertExtraHosts(service.ExtraHosts), Env: convertEnvironment(service.Environment), Labels: getStackLabels(namespace.name, service.Labels), Dir: service.WorkingDir, @@ -521,6 +522,14 @@ func convertService( return serviceSpec, nil } +func convertExtraHosts(extraHosts map[string]string) []string { + hosts := []string{} + for host, ip := range extraHosts { + hosts = append(hosts, fmt.Sprintf("%s %s", host, ip)) + } + return hosts +} + func convertRestartPolicy(restart string, source *composetypes.RestartPolicy) (*swarm.RestartPolicy, error) { // TODO: log if restart is being ignored if source == nil {