diff --git a/biz/docker/service.go b/biz/docker/service.go index ad88114..7067192 100644 --- a/biz/docker/service.go +++ b/biz/docker/service.go @@ -311,7 +311,11 @@ func ServiceUpdate(info *model.ServiceInfo) error { // nolint: gocyclo } } - // DNS + // Host & DNS + spec.TaskTemplate.ContainerSpec.Hostname = info.Hostname + if info.Hosts != "" { + spec.TaskTemplate.ContainerSpec.Hosts = strings.Split(info.Hosts, "\n") + } spec.TaskTemplate.ContainerSpec.DNSConfig = info.GetDNSConfig() options := types.ServiceUpdateOptions{ @@ -521,7 +525,11 @@ func ServiceCreate(info *model.ServiceInfo) error { // nolint: gocyclo } } - // DNS + // Host & DNS + service.TaskTemplate.ContainerSpec.Hostname = info.Hostname + if info.Hosts != "" { + service.TaskTemplate.ContainerSpec.Hosts = strings.Split(info.Hosts, "\n") + } service.TaskTemplate.ContainerSpec.DNSConfig = info.GetDNSConfig() opts := types.ServiceCreateOptions{EncodedRegistryAuth: info.RegistryAuth} diff --git a/model/docker.go b/model/docker.go index 375145e..dbdcb4b 100644 --- a/model/docker.go +++ b/model/docker.go @@ -236,6 +236,8 @@ type ServiceInfo struct { Search string `json:"search,omitempty"` Options string `json:"options,omitempty"` } `json:"dns"` + Hostname string `json:"hostname"` + Hosts string `json:"hosts"` } func NewServiceInfo(service swarm.Service) *ServiceInfo { @@ -347,6 +349,10 @@ func NewServiceInfo(service swarm.Service) *ServiceInfo { si.DNS.Search = strings.Join(dns.Search, ",") si.DNS.Options = strings.Join(dns.Options, ",") } + si.Hostname = spec.TaskTemplate.ContainerSpec.Hostname + if len(spec.TaskTemplate.ContainerSpec.Hosts) > 0 { + si.Hosts = strings.Join(spec.TaskTemplate.ContainerSpec.Hosts, "\n") + } return si } diff --git a/views/_modules/service.jet b/views/_modules/service.jet index 1f395db..50af073 100644 --- a/views/_modules/service.jet +++ b/views/_modules/service.jet @@ -100,7 +100,7 @@