Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option in job-run config to set the container hostname #240

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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