Skip to content

Commit 8c3b580

Browse files
committed
Override network mtu value
1 parent 0b22813 commit 8c3b580

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

0 commit comments

Comments
 (0)