Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Use default container hostname instead of localhost (fixes #1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Apr 11, 2023
1 parent bbe4a19 commit 67eb972
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions service/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,18 @@ func (d *Docker) StartWithCancel() (*StartedService, error) {
}
cl := d.Client
env := getEnv(d.ServiceBase, d.Caps)
cfg := &ctr.Config{
Image: image.(string),
Env: env,
ExposedPorts: portConfig.ExposedPorts,
Labels: getLabels(d.Service, d.Caps),
}
hn := getContainerHostname(d.Caps)
if hn != "" {
cfg.Hostname = hn
}
container, err := cl.ContainerCreate(ctx,
&ctr.Config{
Hostname: getContainerHostname(d.Caps),
Image: image.(string),
Env: env,
ExposedPorts: portConfig.ExposedPorts,
Labels: getLabels(d.Service, d.Caps),
},
cfg,
&hostConfig,
&network.NetworkingConfig{}, nil, "")
if err != nil {
Expand Down Expand Up @@ -405,7 +409,7 @@ func getContainerHostname(caps session.Caps) string {
if caps.ContainerHostname != "" {
return caps.ContainerHostname
}
return "localhost"
return ""
}

func getExtraHosts(service *config.Browser, caps session.Caps) []string {
Expand Down

0 comments on commit 67eb972

Please sign in to comment.