MCPcopy Index your code
hub / github.com/coder/envbox / dockerdArgs

Function dockerdArgs

cli/docker.go:849–882  ·  view source on GitHub ↗

nolint:revive

(link, cidr string, isNoSpace bool)

Source from the content-addressed store, hash-verified

847
848//nolint:revive
849func dockerdArgs(link, cidr string, isNoSpace bool) ([]string, error) {
850 // We need to adjust the MTU for the host otherwise packets will fail delivery.
851 // 1500 is the standard, but certain deployments (like GKE) use custom MTU values.
852 // See: https://www.atlantis-press.com/journals/ijndc/125936177/view#sec-s3.1
853
854 mtu, err := xunix.NetlinkMTU(link)
855 if err != nil {
856 return nil, xerrors.Errorf("custom mtu: %w", err)
857 }
858
859 // We set the Docker Bridge IP explicitly here for a number of reasons:
860 // 1) It sometimes picks the 172.17.x.x address which conflicts with that of the Docker daemon in the inner container.
861 // 2) It defaults to a /16 network which is way more than we need for envbox.
862 // 3) The default may conflict with existing internal network resources, and an operator may wish to override it.
863 dockerBip, prefixLen := dockerutil.BridgeIPFromCIDR(cidr)
864
865 args := []string{
866 "--debug",
867 "--log-level=debug",
868 fmt.Sprintf("--mtu=%d", mtu),
869 "--userns-remap=coder",
870 "--storage-driver=overlay2",
871 fmt.Sprintf("--bip=%s/%d", dockerBip, prefixLen),
872 }
873
874 if isNoSpace {
875 args = append(args,
876 fmt.Sprintf("--data-root=%s", noSpaceDataDir),
877 fmt.Sprintf("--storage-driver=%s", noSpaceDockerDriver),
878 )
879 }
880
881 return args, nil
882}
883
884// TODO This is bad code.
885func filterElements(ss []string, filters ...string) []string {

Callers 1

dockerCmdFunction · 0.85

Calls 3

NetlinkMTUFunction · 0.92
BridgeIPFromCIDRFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected