Skip to content

Commit 24e5544

Browse files
committed
Override network mtu value
1 parent 9a131a0 commit 24e5544

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

0 commit comments

Comments
 (0)