Skip to content

Commit

Permalink
Add option in job-run config to set the container hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
jsixface authored and taraspos committed Jan 21, 2024
1 parent 3e1bc17 commit a1bb40e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/runjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type RunJob struct {

Image string
Network string
Hostname string
Container string
Volume []string
Environment []string
Expand Down Expand Up @@ -171,6 +172,7 @@ func (j *RunJob) buildContainer() (*docker.Container, error) {
Cmd: args.GetArgs(j.Command),
User: j.User,
Env: j.Environment,
Hostname: j.Hostname,
},
NetworkingConfig: &docker.NetworkingConfig{},
HostConfig: &docker.HostConfig{
Expand Down
2 changes: 2 additions & 0 deletions core/runjob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (s *SuiteRunJob) TestRun(c *C) {
job.TTY = true
job.Delete = "true"
job.Network = "foo"
job.Hostname = "test-host"
job.Name = "test"
job.Environment = []string{"test_Key1=value1", "test_Key2=value2"}
job.Volume = []string{"/test/tmp:/test/tmp:ro", "/test/tmp:/test/tmp:rw"}
Expand Down Expand Up @@ -68,6 +69,7 @@ func (s *SuiteRunJob) TestRun(c *C) {
c.Assert(container.Config.Env, DeepEquals, job.Environment)

// this doesn't seem to be working with DockerTestServer
// c.Assert(container.Config.Hostname, Equals, job.Hostname)
// c.Assert(container.HostConfig.Binds, DeepEquals, job.Volume)

// stop container, we don't need it anymore
Expand Down
4 changes: 4 additions & 0 deletions docs/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ This job can be used in 2 situations:
- *description*: Connect the container to this network
- *value*: String, e.g. `backend-proxy`
- *default*: Optional field, no default.
- **Hostname** (1)
- *description*: Define the hostname of the instantiated container
- *value*: String, e.g. `test-server`
- *default*: Optional field, no default.
- **Delete** (1)
- *description*: Delete the container after the job is finished. Similar to `docker run --rm`
- *value*: Boolean, either `true` or `false`
Expand Down

0 comments on commit a1bb40e

Please sign in to comment.