{"record":{"id":"9e9733f7bd73cb7d","repo":"docker/compose","slug":"the-service-level-mac-address-should-have-the-same","errorCode":null,"errorMessage":"the service-level mac_address should have the same value as network %s","messagePattern":"the service-level mac_address should have the same value as network (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/create.go","lineNumber":458,"sourceCode":"// also deprecates the container-wide mac_address field. Thus, this method will validate service config and mutate the\n// passed mainNw to provide backward-compatibility whenever possible.\n//\n// It returns the container-wide MAC address, but this value will be kept empty for newer API versions.\nfunc (s *composeService) prepareContainerMACAddress(service types.ServiceConfig, mainNw *types.ServiceNetworkConfig, nwName string) error {\n\t// Engine API 1.44 added support for endpoint-specific MAC address and now returns a warning when a MAC address is\n\t// set in container.Config. Thus, we have to jump through a number of hoops:\n\t//\n\t// 1. Top-level mac_address and main endpoint's MAC address should be the same ;\n\t// 2. If supported by the API, top-level mac_address should be migrated to the main endpoint and container.Config\n\t//    should be kept empty ;\n\t// 3. Otherwise, the endpoint mac_address should be set in container.Config and no other endpoint-specific\n\t//    mac_address can be specified. If that's the case, use top-level mac_address ;\n\t//\n\t// After that, if an endpoint mac_address is set, it's either user-defined or migrated by the code below, so\n\t// there's no need to check for API version in defaultNetworkSettings.\n\tmacAddress := service.MacAddress\n\tif macAddress != \"\" && mainNw != nil && mainNw.MacAddress != \"\" && mainNw.MacAddress != macAddress {\n\t\treturn fmt.Errorf(\"the service-level mac_address should have the same value as network %s\", nwName)\n\t}\n\tif mainNw != nil && mainNw.MacAddress == \"\" {\n\t\tmainNw.MacAddress = macAddress\n\t}\n\treturn nil\n}\n\nfunc getAliases(project *types.Project, service types.ServiceConfig, serviceIndex int, cfg *types.ServiceNetworkConfig, useNetworkAliases bool) []string {\n\taliases := []string{getContainerName(project.Name, service, serviceIndex)}\n\tif useNetworkAliases {\n\t\taliases = append(aliases, service.Name)\n\t\tif cfg != nil {\n\t\t\taliases = append(aliases, cfg.Aliases...)\n\t\t}\n\t}\n\treturn aliases\n}\n","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/create.go#L440-L476","documentation":"Error \"the service-level mac_address should have the same value as network %s\" thrown in docker/compose.","triggerScenarios":"The service-level mac_address conflicts with the mac_address set for that service inside a network-specific configuration; both must match.","commonSituations":"mac_address is set at the service level and again under networks.<name> with a different value for the same service.","solutions":["Set mac_address only in one place: either at service level or under the network configuration, with the same value.","Remove the service-level mac_address if the network-level one is authoritative."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}