Skip to content

Commit

Permalink
Merge 4bf5e4f into 05646d9
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcooperxyz committed Jan 11, 2021
2 parents 05646d9 + 4bf5e4f commit b1206b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dockertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ type RunOptions struct {
Auth dc.AuthConfiguration
PortBindings map[dc.Port][]dc.PortBinding
Privileged bool
User string
}

// BuildOptions is used to pass in optional parameters when building a container
Expand Down Expand Up @@ -433,6 +434,7 @@ func (d *Pool) RunWithOptions(opts *RunOptions, hcOpts ...func(*dc.HostConfig))
WorkingDir: wd,
Labels: opts.Labels,
StopSignal: "SIGWINCH", // to support timeouts
User: opts.User,
},
HostConfig: &hostConfig,
NetworkingConfig: &networkingConfig,
Expand Down
20 changes: 20 additions & 0 deletions dockertest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ func TestContainerWithLabels(t *testing.T) {
require.Nil(t, pool.Purge(resource))
}

func TestContainerWithUser(t *testing.T) {
user := "1001:1001"
resource, err := pool.RunWithOptions(
&RunOptions{
Name: "db",
Repository: "postgres",
Tag: "9.5",
User: user,
Env: []string{"POSTGRES_PASSWORD=secret"},
})
require.Nil(t, err)
assert.EqualValues(t, user, resource.Container.Config.User, "users don't match")

res, err := pool.Client.InspectContainer(resource.Container.ID)
require.Nil(t, err)
assert.Equal(t, user, res.Config.User)

require.Nil(t, pool.Purge(resource))
}

func TestContainerWithPortBinding(t *testing.T) {
resource, err := pool.RunWithOptions(
&RunOptions{
Expand Down

0 comments on commit b1206b9

Please sign in to comment.