Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Add extra host to start command (#369)
Browse files Browse the repository at this point in the history
* Add extra host to start command

Signed-off-by: Kevin Su <[email protected]>

* Fix tests

Signed-off-by: Kevin Su <[email protected]>

* Fix tests

Signed-off-by: Kevin Su <[email protected]>

* Make generate

Signed-off-by: Kevin Su <[email protected]>

* update

Signed-off-by: Kevin Su <[email protected]>

Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw authored Nov 10, 2022
1 parent 77deca5 commit 209fe93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/docker/docker_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
}
StdWriterPrefixLen = 8
StartingBufLen = 32*1024 + StdWriterPrefixLen + 1
ExtraHosts = []string{"host.docker.internal:127.0.0.1"}
)

// GetDockerClient will returns the docker client
Expand Down Expand Up @@ -237,6 +238,7 @@ func StartContainer(ctx context.Context, cli Docker, volumes []mount.Mount, expo
Mounts: volumes,
PortBindings: portBindings,
Privileged: true,
ExtraHosts: ExtraHosts, // add it because linux machine doesn't have this host name by default
}, nil,
nil, name)

Expand Down
4 changes: 4 additions & 0 deletions pkg/docker/docker_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func TestStartContainer(t *testing.T) {
Mounts: Volumes,
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
ID: "Hello",
}, nil)
Expand Down Expand Up @@ -185,6 +186,7 @@ func TestStartContainer(t *testing.T) {
Mounts: Volumes,
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
ID: "Hello",
}, nil)
Expand All @@ -211,6 +213,7 @@ func TestStartContainer(t *testing.T) {
Mounts: Volumes,
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
ID: "",
}, fmt.Errorf("error"))
Expand All @@ -236,6 +239,7 @@ func TestStartContainer(t *testing.T) {
Mounts: Volumes,
PortBindings: p2,
Privileged: true,
ExtraHosts: ExtraHosts,
}, nil, nil, mock.Anything).Return(container.ContainerCreateCreatedBody{
ID: "Hello",
}, nil)
Expand Down

0 comments on commit 209fe93

Please sign in to comment.