Skip to content

Commit

Permalink
Merge pull request #439 from travis-ci/aj-docker-tags
Browse files Browse the repository at this point in the history
More docker container labels (ipv4, instance id)
  • Loading branch information
soulshake authored Feb 20, 2018
2 parents c62379b + 4e46c72 commit 64df403
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions backend/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"path/filepath"
Expand Down Expand Up @@ -387,6 +388,20 @@ func (p *dockerProvider) Start(ctx gocontext.Context, startAttributes *StartAttr
labels["travis.job_id"] = strconv.FormatUint(jid, 10)
}

ipv4, err := ioutil.ReadFile("/var/tmp/travis-run.d/instance-ipv4")
if err != nil {
logger.WithField("err", err).Error("couldn't read instance IP from /var/tmp/travis-run.d/instance-ipv4")
} else {
labels["travis.ipv4"] = string(ipv4)
}

iid, err := ioutil.ReadFile("/var/tmp/travis-run.d/instance-id")
if err != nil {
logger.WithField("err", err).Error("couldn't read instance ID from /var/tmp/travis-run.d/instance-id")
} else {
labels["travis.instance_id"] = string(iid)
}

dockerConfig := &dockercontainer.Config{
Cmd: p.runCmd,
Image: imageID,
Expand Down

0 comments on commit 64df403

Please sign in to comment.