<p>What patterns are valid in kubernetes for the names of containers and ports?</p>

<p>I had underscores in the names of ports and containers and got an error. Replacing the underscores with hyphens worked.</p>

<p>Container names and port names must conform to the <a href="https://www.rfc-editor.org/rfc/rfc1123#section-2" rel="nofollow noreferrer">RFC 1123 definition</a> of a DNS label.</p>
<p>Names must be no longer than 63 characters, must start and end with a lowercase letter or number, and may contain lowercase letters, numbers, and hyphens.</p>
<p>Expressed as a regular expression:</p>
<pre><code>[a-z0-9]([-a-z0-9]*[a-z0-9])?
</code></pre>
<p>Here's the applicable code in GitHub for <a href="https://github.com/GoogleCloudPlatform/kubernetes/blob/53a9d106c4aabcd550cc32ae4e8004f32fb0ae7b/pkg/api/validation/validation.go#L280" rel="nofollow noreferrer">checking container names</a>, <a href="https://github.com/GoogleCloudPlatform/kubernetes/blob/53a9d106c4aabcd550cc32ae4e8004f32fb0ae7b/pkg/api/validation/validation.go#L133" rel="nofollow noreferrer">checking port names</a>, and <a href="https://github.com/GoogleCloudPlatform/kubernetes/blob/7f2d0c0f710617ef1f5eec4745b23e0d3f360037/pkg/util/validation.go#L26" rel="nofollow noreferrer">defining acceptable names</a>.</p>
