Skip to content

Commit fd1ddbf

Browse files
aledbfkylos101
authored andcommitted
Override network mtu value
1 parent 9c0b922 commit fd1ddbf

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
@@ -46,6 +46,7 @@ import (
4646
"github.com/docker/go-connections/nat"
4747
"github.com/docker/go-units"
4848
"github.com/sirupsen/logrus"
49+
"github.com/vishvananda/netlink"
4950

5051
"github.com/docker/compose/v2/pkg/api"
5152
"github.com/docker/compose/v2/pkg/progress"
@@ -1278,6 +1279,19 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, n *types.Ne
12781279
}
12791280
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
12801281
}
1282+
1283+
// override MTU value and set custom MTU one.
1284+
// This is required for gitpod.io due to the veth change
1285+
// https://github.com/gitpod-io/gitpod/pull/8955
1286+
if createOpts.Options == nil {
1287+
createOpts.Options = make(map[string]string)
1288+
}
1289+
1290+
netIface, err := netlink.LinkByName("ceth0")
1291+
if err == nil {
1292+
createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU)
1293+
}
1294+
12811295
networkEventName := fmt.Sprintf("Network %s", n.Name)
12821296
w := progress.ContextWriter(ctx)
12831297
w.Event(progress.CreatingEvent(networkEventName))

0 commit comments

Comments
 (0)