Kubernetes CreateContainerConfigError and CreateContainerError
Tags: kubernetes, monitoring, cloud, devops
Published: 2023-03-23 15:58:05

---
title: Kubernetes CreateContainerConfigError and CreateContainerError
published: true
description: CreateContainerError and CreateContainerConfigError are two of the most prevalent errors in Kubernetes. Check this article for their differences and their causes.

tags: kubernetes, monitoring, cloud, devops
cover_image: https://sysdig.com/wp-content/uploads/CreateContainerError-featured.png
canonical_url: https://sysdig.com/blog/kubernetes-createcontainerconfigerror-createcontainererror/
# Use a ratio of 100:42 for best results.
---

<!-- wp:paragraph -->
<p>CreateContainerConfigError and CreateContainerError are two of the most prevalent Kubernetes errors found in cloud-native applications.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>CreateContainerConfigError</strong> is an error happening when the <strong>configuration specified for a container in a Pod is not correct</strong> or is missing a vital part.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>CreateContainerError</strong> is a problem happening<strong> at a later stage</strong> in the container creation flow. Kubernetes displays this error when it attempts to create the container in the Pod.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In this article, you will learn:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li><a href="#what-is-createcontainerconfigerror">What is Kubernetes CreateContainerConfigError?</a></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><a href="#what-is-createcontainererror">What is Kubernetes CreateContainerError?</a></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><a href="#container-creation-flow">Kubernetes container creation flow</a></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><a href="#common-causes-createcontainerconfigerror">Common causes for CreateContainerError and CreateConfigError</a></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><a href="#troubleshoot">How to troubleshoot both errors</a></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><a href="#how-to-detect">How to detect both errors in Prometheus</a></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2 id="what-is-createcontainerconfigerror">What is CreateContainerConfigError?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>During the process to start a new container, Kubernetes first tries to generate the configuration for it. In fact, this is handled internally by calling a method called <em>generateContainerConfig</em>, which will try to retrieve:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Container command and arguments</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Relevant persistent volumes for the container</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Relevant ConfigMaps for the container</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Relevant secrets for the container</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Any problem in the elements above will result in a CreateContainerConfigError.  </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="what-is-createcontainererror">What is CreateContainerError?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Kubernetes throws a CreateContainerError when there’s a problem in the creation of the container, but unrelated with configuration, like a referenced volume not being accessible or a container name already being used.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><span style="text-size: smaller; font-style: italic; border: 1px solid #FF9E1B; display: block; border-radius: 25px; padding: 25px; max-width: 96%; margin: 2em auto;"><em>Similar to other problems like <a href="https://sysdig.com/blog/debug-kubernetes-crashloopbackoff/">CrashLoopBackOff</a>, this article only covers the most common causes, but there are many others depending on your current application.</em><span style="font-size: revert; color: initial; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen-Sans, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, sans-serif;"></span></span></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>How you can detect CreateContainerConfigError and CreateContainerError</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can detect both errors by running kubectl get pods:</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"yaml"} -->
<pre class="wp-block-code"><code>NAME  READY STATUS                     RESTARTS AGE

mypod 0/1   CreateContainerConfigError 0        11m</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>As you can see from this output:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Pod is not ready: container has an error.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>There are no restarts: these two errors are not like CrashLoopBackOff, where automatic retrials are in place.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2 id="container-creation-flow">Kubernetes container creation flow</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In order to understand CreateContainerError and CreateContainerConfligError, we need to first know the exact flow for container creation.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Kubernetes follows the next steps every time a new container needs to be started:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><!-- wp:list-item -->
<li>Pull the image.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Generate container configuration.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Precreate container.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Create container.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Pre-start container.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Start container.</li>
<!-- /wp:list-item --></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>As you can see, steps 2 and 4 are where a CreateContainerConfig and CreateContainerErorr might appear, respectively.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":69369,"width":878,"height":348,"sizeSlug":"large","linkDestination":"custom"} -->
<figure class="wp-block-image size-large is-resized"><a href="https://sysdig.com/wp-content/uploads/Createcontainererror-02-1170x464.png"><img src="https://sysdig.com/wp-content/uploads/Createcontainererror-02-1170x464.png" alt="Create container and start container flow" class="wp-image-69369" width="878" height="348"/></a></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 id="common-causes-createcontainerconfigerror">Common causes for CreateContainerError and CreateContainerConfigError</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3>Not found ConfigMap</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Kubernetes <a href="https://kubernetes.io/docs/concepts/configuration/configmap/">ConfigMaps</a> are a key element to store non-confidential information to be used by Pods as key-value pairs.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>When adding a ConfigMap reference in a Pod, you are effectively indicating that it should retrieve specific data from it. But, if a Pod references a non-existent ConfigMap, Kubernetes will return a CreateContainerConfigError.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Not found Secret</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Secrets are a more secure manner to store sensitive information in Kubernetes. Remember, though, this is just raw data encoded in base64, so it’s not really encrypted, just obfuscated.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In case a Pod contains a reference to a non-existent secret, Kubelet will throw a CreateContainerConfigError, indicating that necessary data couldn’t be retrieved in order to form container config.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Container name already in use</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While an unusual situation, in some cases a conflict might occur because a particular container name is already being used. Since every docker container should have a unique name, you will need to either delete the original or rename the new one being created.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="troubleshoot">How to troubleshoot CreateContainerError and CreateContainerConfigError</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While the causes for an error in container creation might vary, you can always rely on the following methods to troubleshoot the problem that’s preventing the container from starting.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Describe Pods</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>With <code>kubectl describe pod</code>, you can retrieve the detailed information for the affected Pod and its containers:</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"yaml"} -->
<pre class="wp-block-code"><code>Containers:
  mycontainer:
    Container ID:
    Image:          nginx
    Image ID:
    Port:           &lt;none&gt;
    Host Port:      &lt;none&gt;
    State:          Waiting
      Reason:       CreateContainerConfigError
    Ready:          False
    Restart Count:  0
    Limits:
      cpu:  3
---
Volumes:
  config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      myconfigmap
    Optional:  false</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>Get logs from containers</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Use <code>kubectl logs</code> to retrieve the log information from containers in the Pod. Note that for Pods with multiple containers, you need to use the <code>–all-containers</code> parameter:</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"yaml","wrapLines":true} -->
<pre class="wp-block-code"><code>Error from server (BadRequest): container "mycontainer" in pod "mypod" is waiting to start: CreateContainerConfigError</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>Check the events</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can also run <code>kubectl get events</code> to retrieve all the recent events happening in your Pods. Remember that the describe pods command also displays the particular events at the end.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":69370,"width":878,"height":440,"sizeSlug":"large","linkDestination":"custom"} -->
<figure class="wp-block-image size-large is-resized"><a href="https://sysdig.com/wp-content/uploads/Createcontainererror-03-1170x586.png"><img src="https://sysdig.com/wp-content/uploads/Createcontainererror-03-1170x586.png" alt="Createcontainerconfig error troubleshooting diagram" class="wp-image-69370" width="878" height="440"/></a><figcaption class="wp-element-caption">Terminal windows for the kubectl commands used to troubleshoot a CreateContainerConfigError</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="detect-in-prometheus">How to detect CreateContainerConfigError and CreateContainerError in Prometheus</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>When using Prometheus + kube-state-metrics, you can quickly retrieve Pods that have containers with errors at creation or config steps:</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"yaml","wrapLines":true} -->
<pre class="wp-block-code"><code>kube_pod_container_status_waiting_reason{reason="CreateContainerConfigError"} &gt; 0
kube_pod_container_status_waiting_reason{reason="CreateContainerError"} &gt; 0</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":69426,"width":878,"height":748,"sizeSlug":"large","linkDestination":"custom"} -->
<figure class="wp-block-image size-large is-resized"><a href="https://sysdig.com/wp-content/uploads/image2-53-1170x997.png"><img src="https://sysdig.com/wp-content/uploads/image2-53-1170x997.png" alt="" class="wp-image-69426" width="878" height="748"/></a></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 id="other-errors">Other similar errors</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3>Pending</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><a href="https://sysdig.com/blog/kubernetes-pod-pending-problems/">Pending is a Pod status</a> that appears when the Pod couldn’t even be started. Note that this happens at schedule time, so Kube-scheduler couldn’t find a node because of not enough resources or not proper taints/tolerations config.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>ContainerCreating</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>ContainerCreating is another waiting status reason that can happen when the container could not be started because of a problem in the execution (e.g: <code>No command specified</code>)</p>
<!-- /wp:paragraph -->

<!-- wp:code {"language":"yaml","wrapLines":true} -->
<pre class="wp-block-code"><code>Error from server (BadRequest): container "mycontainer" in pod "mypod" is waiting to start: ContainerCreating   </code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>RunContainerError</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>This might be a similar situation to CreateContainerError, but note that this happens during the run step and not the container creation step.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A RunContainerError most likely points to problems happening at runtime, like attempts to write on a read-only volume.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>CrashLoopBackOff</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Remember that <a href="https://sysdig.com/blog/debug-kubernetes-crashloopbackoff/">CrashLoopBackOff</a> is not technically an error, but the waiting time grace period that is added between retrials.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Unlike CrashLoopBackOff events, CreateContainerError and CreateContainerConfigError won’t be retried automatically.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Conclusion</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In this article, you have seen how both CreateContainerConfigError and CreateContainerError are important messages in the Kubernetes container creation process. Being able to detect them and understand at which stage they are happening is crucial for the day-to-day debugging of cloud-native services.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Also, it’s important to know the internal behavior of the Kubernetes container creation flow and what is errors might appear at each step.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Finally, CreateContainerConfigError and CreateContainerError might be mistaken with other different Kubernetes errors, but these two happen at container creation stage and they are not automatically retried.</p>
<!-- /wp:paragraph -->

<!-- wp:separator -->
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<!-- /wp:separator -->

<!-- wp:html -->
<div class="sysdig-box" style="background-color: #f8f8f8; padding: 2em;">
<h2 style="margin-top: 0;"><em>Troubleshoot CreateContainerError with Sysdig Monitor
</em></h2>
<p>With Sysdig Monitor’s Advisor, you can easily detect which containers are having CreateContainerConfigError or CreateContainerError problems in your Kubernetes cluster.</p>
<p>Advisor accelerates mean time to resolution (MTTR) with live logs, performance data, and suggested remediation steps. It’s the easy button for Kubernetes troubleshooting!</p>

<figure><a href="https://sysdig.com/wp-content/uploads/image3-39-1170x579.png" target="_blank" rel="noopener"><img src="https://sysdig.com/wp-content/uploads/image3-39-1170x579.png" alt="Rightsize your Kubernetes Resources with Sysdig Monitor" width="1438" height="899" class="aligncenter size-full wp-image-53165"></a></figure><p></p>

<p><a href="https://sysdig.com/start-free/">Try it free</a> for 30 days!</p></div>
<!-- /wp:html -->