Skip to content

Commit d849f5c

Browse files
committed
Override network mtu value
1 parent 14ca112 commit d849f5c

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
@@ -40,6 +40,7 @@ import (
4040
"github.com/docker/go-units"
4141
"github.com/pkg/errors"
4242
"github.com/sirupsen/logrus"
43+
"github.com/vishvananda/netlink"
4344

4445
"github.com/docker/compose/v2/pkg/api"
4546
"github.com/docker/compose/v2/pkg/progress"
@@ -1052,6 +1053,19 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
10521053
}
10531054
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
10541055
}
1056+
1057+
// override MTU value and set custom MTU one.
1058+
// This is required for gitpod.io due to the veth change
1059+
// https://github.com/gitpod-io/gitpod/pull/8955
1060+
if createOpts.Options == nil {
1061+
createOpts.Options = make(map[string]string)
1062+
}
1063+
1064+
netIface, err := netlink.LinkByName("ceth0")
1065+
if err == nil {
1066+
createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU)
1067+
}
1068+
10551069
networkEventName := fmt.Sprintf("Network %s", n.Name)
10561070
w := progress.ContextWriter(ctx)
10571071
w.Event(progress.CreatingEvent(networkEventName))

0 commit comments

Comments
 (0)