diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index d6c6f45..865a12f 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -178,6 +178,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
   protected $containerNeedsDumping;
 
   /**
+   * Whether the container can be cached.
+   *
+   * @var bool
+   */
+  protected $allowCaching = TRUE;
+
+  /**
    * List of discovered services.yml pathnames.
    *
    * This is a nested array whose top-level keys are 'app' and 'site', denoting
@@ -865,7 +872,7 @@ protected function initializeContainer() {
     \Drupal::setContainer($this->container);
 
     // If needs dumping flag was set, dump the container.
-    if ($this->containerNeedsDumping && !$this->cacheDrupalContainer($container_definition)) {
+    if ($this->allowCaching && $this->containerNeedsDumping && !$this->cacheDrupalContainer($container_definition)) {
       $this->container->get('logger.factory')->get('DrupalKernel')->notice('Container cannot be saved to cache.');
     }
 
diff --git a/core/lib/Drupal/Core/Update/UpdateKernel.php b/core/lib/Drupal/Core/Update/UpdateKernel.php
index 80f243c..32314f9 100644
--- a/core/lib/Drupal/Core/Update/UpdateKernel.php
+++ b/core/lib/Drupal/Core/Update/UpdateKernel.php
@@ -43,16 +43,10 @@ protected function initializeContainer() {
     // services, see \Drupal\Core\Update\UpdateServiceProvider.
     $this->containerNeedsRebuild = TRUE;
     $container = parent::initializeContainer();
-    return $container;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function cacheDrupalContainer(array $container_definition) {
     // Don't save this particular container to cache, so it does not leak into
     // the main site at all.
-    return FALSE;
+    $this->allowCaching = FALSE;
+    return $container;
   }
 
   /**
