Skip to content

Commit 144607b

Browse files
committed
Override network mtu value
1 parent 6756732 commit 144607b

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"
@@ -1055,6 +1056,19 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
10551056
}
10561057
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
10571058
}
1059+
1060+
// override MTU value and set custom MTU one.
1061+
// This is required for gitpod.io due to the veth change
1062+
// https://github.com/gitpod-io/gitpod/pull/8955
1063+
if createOpts.Options == nil {
1064+
createOpts.Options = make(map[string]string)
1065+
}
1066+
1067+
netIface, err := netlink.LinkByName("ceth0")
1068+
if err == nil {
1069+
createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU)
1070+
}
1071+
10581072
networkEventName := fmt.Sprintf("Network %s", n.Name)
10591073
w := progress.ContextWriter(ctx)
10601074
w.Event(progress.CreatingEvent(networkEventName))

0 commit comments

Comments
 (0)