Skip to content

Commit

Permalink
Override network mtu value
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Aug 22, 2022
1 parent f880b41 commit e16ff58
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/compose/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"

"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/progress"
Expand Down Expand Up @@ -1109,6 +1110,19 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
}
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
}

// override MTU value and set custom MTU one.
// This is required for gitpod.io due to the veth change
// https://github.com/gitpod-io/gitpod/pull/8955
if createOpts.Options == nil {
createOpts.Options = make(map[string]string)
}

netIface, err := netlink.LinkByName("ceth0")
if err == nil {
createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU)
}

networkEventName := fmt.Sprintf("Network %s", n.Name)
w := progress.ContextWriter(ctx)
w.Event(progress.CreatingEvent(networkEventName))
Expand Down

0 comments on commit e16ff58

Please sign in to comment.