diff --git a/CHANGELOG.md b/CHANGELOG.md index 542b8660c..a29201341 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). ### Removed ### Fixed +- backend/docker: switch to container hostname with dashes instead of dots ### Security diff --git a/backend/docker.go b/backend/docker.go index f2c7d4139..2d474ed1b 100644 --- a/backend/docker.go +++ b/backend/docker.go @@ -707,7 +707,7 @@ func findDockerImageByTag(searchTags []string, images []dockertypes.ImageSummary } func containerNameFromContext(ctx gocontext.Context) string { - randName := fmt.Sprintf("travis-job.unk.unk.%s", uuid.NewRandom()) + randName := fmt.Sprintf("travis-job-unk-unk-%s", uuid.NewRandom()) jobID, ok := context.JobIDFromContext(ctx) if !ok { return randName @@ -733,5 +733,5 @@ func containerNameFromContext(ctx gocontext.Context) string { nameParts = append(nameParts, cleanedPart) } - return strings.Join(append(nameParts, fmt.Sprintf("%v", jobID)), ".") + return strings.Join(append(nameParts, fmt.Sprintf("%v", jobID)), "-") } diff --git a/backend/docker_test.go b/backend/docker_test.go index 766b73b1a..55f77e3ae 100644 --- a/backend/docker_test.go +++ b/backend/docker_test.go @@ -589,11 +589,11 @@ func TestDocker_containerNameFromContext(t *testing.T) { for _, tc := range []struct{ r, n string }{ { r: "friendly/fribble", - n: fmt.Sprintf("travis-job.friendly.fribble.%v", jobID), + n: fmt.Sprintf("travis-job-friendly-fribble-%v", jobID), }, { r: "very-SiLlY.nAmE.wat/por-cu-pine", - n: fmt.Sprintf("travis-job.very-SiLlY-nAm.por-cu-pine.%v", jobID), + n: fmt.Sprintf("travis-job-very-SiLlY-nAm-por-cu-pine-%v", jobID), }, } { ctx := context.FromRepository(context.FromJobID(gocontext.TODO(), jobID), tc.r) @@ -601,8 +601,8 @@ func TestDocker_containerNameFromContext(t *testing.T) { } randName := containerNameFromContext(gocontext.TODO()) - randParts := strings.Split(randName, ".") - assert.Len(t, randParts, 4) - assert.Equal(t, "unk", randParts[1]) + randParts := strings.Split(randName, "-") + assert.Len(t, randParts, 9) assert.Equal(t, "unk", randParts[2]) + assert.Equal(t, "unk", randParts[3]) }