Skip to content

Commit 0043d61

Browse files
aledbfgeropl
authored andcommitted
Override network mtu value
1 parent a8bfbc1 commit 0043d61

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/compose/create.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ import (
4848
"github.com/docker/go-connections/nat"
4949
"github.com/sirupsen/logrus"
5050
cdi "tags.cncf.io/container-device-interface/pkg/parser"
51+
"github.com/vishvananda/netlink"
52+
53+
"github.com/docker/compose/v2/pkg/api"
54+
"github.com/docker/compose/v2/pkg/progress"
55+
"github.com/docker/compose/v2/pkg/utils"
5156
)
5257

5358
type createOptions struct {
@@ -1318,6 +1323,19 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, n *types.Ne
13181323
}
13191324
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
13201325
}
1326+
1327+
// override MTU value and set custom MTU one.
1328+
// This is required for gitpod.io due to the veth change
1329+
// https://github.com/gitpod-io/gitpod/pull/8955
1330+
if createOpts.Options == nil {
1331+
createOpts.Options = make(map[string]string)
1332+
}
1333+
1334+
netIface, err := netlink.LinkByName("ceth0")
1335+
if err == nil {
1336+
createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU)
1337+
}
1338+
13211339
networkEventName := fmt.Sprintf("Network %s", n.Name)
13221340
w := progress.ContextWriter(ctx)
13231341
w.Event(progress.CreatingEvent(networkEventName))

0 commit comments

Comments
 (0)