Skip to content

Commit 2fdf992

Browse files
authored
Merge pull request moby#3680 from jedevc/gateway-container-hostname
gateway: add hostname option to NewContainer API
2 parents fa9ba9b + 9128ebc commit 2fdf992

File tree

7 files changed

+213
-153
lines changed

7 files changed

+213
-153
lines changed

frontend/gateway/client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type Client interface {
3838
// new container, without defining the initial process.
3939
type NewContainerRequest struct {
4040
Mounts []Mount
41+
Hostname string
4142
NetMode pb.NetMode
4243
ExtraHosts []*pb.HostIP
4344
Platform *pb.Platform

frontend/gateway/container.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
type NewContainerRequest struct {
3030
ContainerID string
3131
NetMode opspb.NetMode
32+
Hostname string
3233
ExtraHosts []executor.HostIP
3334
Mounts []Mount
3435
Platform *opspb.Platform
@@ -56,6 +57,7 @@ func NewContainer(ctx context.Context, w worker.Worker, sm *session.Manager, g s
5657
ctr := &gatewayContainer{
5758
id: req.ContainerID,
5859
netMode: req.NetMode,
60+
hostname: req.Hostname,
5961
extraHosts: req.ExtraHosts,
6062
platform: platform,
6163
executor: w.Executor(),
@@ -280,6 +282,7 @@ func PrepareMounts(ctx context.Context, mm *mounts.MountManager, cm cache.Manage
280282
type gatewayContainer struct {
281283
id string
282284
netMode opspb.NetMode
285+
hostname string
283286
extraHosts []executor.HostIP
284287
platform opspb.Platform
285288
rootFS executor.Mount
@@ -304,6 +307,7 @@ func (gwCtr *gatewayContainer) Start(_ context.Context, req client.StartRequest)
304307
Cwd: req.Cwd,
305308
Tty: req.Tty,
306309
NetMode: gwCtr.netMode,
310+
Hostname: gwCtr.hostname,
307311
ExtraHosts: gwCtr.extraHosts,
308312
SecurityMode: req.SecurityMode,
309313
RemoveMountStubsRecursive: req.RemoveMountStubsRecursive,

frontend/gateway/forwarder/forward.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func (c *bridgeClient) NewContainer(ctx context.Context, req client.NewContainer
235235
ctrReq := gateway.NewContainerRequest{
236236
ContainerID: identity.NewID(),
237237
NetMode: req.NetMode,
238+
Hostname: req.Hostname,
238239
Mounts: make([]gateway.Mount, len(req.Mounts)),
239240
}
240241

frontend/gateway/gateway.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ func (lbf *llbBridgeForwarder) NewContainer(ctx context.Context, in *pb.NewConta
957957
ctrReq := NewContainerRequest{
958958
ContainerID: in.ContainerID,
959959
NetMode: in.Network,
960+
Hostname: in.Hostname,
960961
Platform: in.Platform,
961962
Constraints: in.Constraints,
962963
}

frontend/gateway/grpcclient/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ func (c *grpcClient) NewContainer(ctx context.Context, req client.NewContainerRe
792792
Constraints: req.Constraints,
793793
Network: req.NetMode,
794794
ExtraHosts: req.ExtraHosts,
795+
Hostname: req.Hostname,
795796
})
796797
if err != nil {
797798
return nil, err

frontend/gateway/pb/gateway.pb.go

Lines changed: 204 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/gateway/pb/gateway.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ message NewContainerRequest {
239239
pb.Platform platform = 4;
240240
pb.WorkerConstraints constraints = 5;
241241
repeated pb.HostIP extraHosts = 6;
242+
string hostname = 7;
242243
}
243244

244245
message NewContainerResponse{}

0 commit comments

Comments
 (0)