GoogleContainerTools/skaffold · error
INIT_DOCKER_NETWORK_INVALID_MODE
INIT_DOCKER_NETWORK_INVALID_MODE
Error message
extracting container name from a non valid container network mode '%s'
What it means
Docker network modes are either 'bridge'/'host'/default or 'container:<name>'. extractContainerNameFromNetworkMode is given a mode it cannot parse into a container name, so it returns an actionable error with code INIT_DOCKER_NETWORK_INVALID_MODE and a fix suggestion.
Source
Thrown at pkg/skaffold/schema/validation/validation.go:330
maybeID := strings.SplitN(mode, ":", 2)[1]
id, err := util.ExpandEnvTemplate(maybeID, map[string]string{})
if err != nil {
return "", sErrors.NewError(err,
&proto.ActionableErr{
Message: fmt.Sprintf("unable to parse container name %s: %s", mode, err),
ErrCode: proto.StatusCode_INIT_DOCKER_NETWORK_PARSE_ERR,
Suggestions: []*proto.Suggestion{
{
SuggestionCode: proto.SuggestionCode_FIX_DOCKER_NETWORK_CONTAINER_NAME,
Action: fmt.Sprintf("Check the content of the environment variable: %s", maybeID),
},
},
})
}
return id, nil
}
errMsg := fmt.Sprintf("extracting container name from a non valid container network mode '%s'", mode)
return "", sErrors.NewError(errors.New(errMsg),
&proto.ActionableErr{
Message: errMsg,
ErrCode: proto.StatusCode_INIT_DOCKER_NETWORK_INVALID_MODE,
Suggestions: []*proto.Suggestion{
{
SuggestionCode: proto.SuggestionCode_FIX_DOCKER_NETWORK_MODE_WHEN_EXTRACTING_CONTAINER_NAME,
Action: "Only container mode allowed when calling 'extractContainerNameFromNetworkMode'",
},
},
})
}
// validateDockerNetworkModeExpression makes sure that the network mode starts with "container:" followed by a valid container name
func validateDockerNetworkModeExpression(image string, expr string) error {
id, err := extractContainerNameFromNetworkMode(expr)
if err != nil {
return err
}View on GitHub (pinned to a1189de023)
Solutions
- Format the network mode as container:<container-name> (e.g. container:mydb).
- Use a supported simple mode (bridge or host) if no container network is intended.
- Follow the suggestion in the actionable error (FIX_DOCKER_NETWORK_MODE_WHEN_EXTRACTING_CONTAINER_NAME).
Example fix
# before networkMode: mydb # after networkMode: container:mydb
Defensive patterns
Strategy: validation
Validate before calling
func parseNetworkMode(mode string) (string, bool) {
switch mode { case "", "bridge", "host": return "", true }
if strings.HasPrefix(mode, "container:") && len(strings.Split(mode, ":")) == 2 {
return strings.TrimPrefix(mode, "container:"), true
}
return "", false
} Type guard
name, ok := parseNetworkMode(mode); if !ok { /* invalid mode */ } Try / catch
_, err := validateDockerNetworkModeExpression(...)
var se *sErrors.Error
if errors.As(err, &se) && se.ErrCode == proto.StatusCode_INIT_DOCKER_NETWORK_INVALID_MODE {
// rewrite mode to container:<name> and retry
} Prevention
- Always use the container:<name> form for container network modes
- Only use bridge/host/empty otherwise
- Avoid extra colons or suffixes in the mode string
When it happens
Trigger: An artifact's sync/automation networkMode string is neither empty/bridge/host nor of the form container:<name>; called from validateDockerNetworkModeExpression and validateDockerNetworkContainerExists.
Common situations: Typos like 'container:foo:extra', 'network:custom', or bare container names missing the 'container:' prefix in skaffold.yaml.
Related errors
- INIT_DOCKER_NETWORK_INVALID_CONTAINER_NAME
- cannot call Run with empty container config
- parsing tag %q: %w
- reading image %q: %w
- parsing reference %q: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/4c07300fc788816d.
Report an issue: GitHub.