Skip to content

Commit e16ff58

Browse files
committed
Override network mtu value
1 parent f880b41 commit e16ff58

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/compose/create.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/docker/go-units"
4242
"github.com/pkg/errors"
4343
"github.com/sirupsen/logrus"
44+
"github.com/vishvananda/netlink"
4445

4546
"github.com/docker/compose/v2/pkg/api"
4647
"github.com/docker/compose/v2/pkg/progress"
@@ -1109,6 +1110,19 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
11091110
}
11101111
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
11111112
}
1113+
1114+
// override MTU value and set custom MTU one.
1115+
// This is required for gitpod.io due to the veth change
1116+
// https://github.com/gitpod-io/gitpod/pull/8955
1117+
if createOpts.Options == nil {
1118+
createOpts.Options = make(map[string]string)
1119+
}
1120+
1121+
netIface, err := netlink.LinkByName("ceth0")
1122+
if err == nil {
1123+
createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU)
1124+
}
1125+
11121126
networkEventName := fmt.Sprintf("Network %s", n.Name)
11131127
w := progress.ContextWriter(ctx)
11141128
w.Event(progress.CreatingEvent(networkEventName))

0 commit comments

Comments
 (0)