Skip to content

Commit 2744c50

Browse files
committed
Override network mtu value
1 parent 68cf8d5 commit 2744c50

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"
@@ -1097,6 +1098,19 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
10971098
}
10981099
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
10991100
}
1101+
1102+
// override MTU value and set custom MTU one.
1103+
// This is required for gitpod.io due to the veth change
1104+
// https://github.com/gitpod-io/gitpod/pull/8955
1105+
if createOpts.Options == nil {
1106+
createOpts.Options = make(map[string]string)
1107+
}
1108+
1109+
netIface, err := netlink.LinkByName("ceth0")
1110+
if err == nil {
1111+
createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU)
1112+
}
1113+
11001114
networkEventName := fmt.Sprintf("Network %s", n.Name)
11011115
w := progress.ContextWriter(ctx)
11021116
w.Event(progress.CreatingEvent(networkEventName))

0 commit comments

Comments
 (0)