diff --git a/core/includes/install.inc b/core/includes/install.inc
index 77e0b70..9c83e2d 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -446,7 +446,9 @@ function _drupal_rewrite_settings_dump($variable, $variable_name) {
  *   into settings.php.
  */
 function _drupal_rewrite_settings_dump_one(\stdClass $variable, $prefix = '', $suffix = '') {
-  $return = $prefix . var_export($variable->value, TRUE) . ';';
+  $export = !isset($variable->export) || !empty($variable->export);
+  $value = $export ? var_export($variable->value, TRUE) : $variable->value;
+  $return = $prefix . $value . ';';
   if (!empty($variable->comment)) {
     $return .= ' // ' . $variable->comment;
   }
diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php
index 4d0f9fe..aca8973 100644
--- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php
+++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php
@@ -176,6 +176,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
       'value'    => Crypt::randomBytesBase64(55),
       'required' => TRUE,
     );
+    $settings['settings']['container_yamls'][0] = (object) array(
+      'value'    => "__DIR__ . '/services.yml'",
+      'export'   => FALSE,
+      'required' => TRUE,
+    );
     // Remember the profile which was used.
     $settings['settings']['install_profile'] = (object) array(
       'value' => $install_state['parameters']['profile'],
diff --git a/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php b/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php
index 63bb9a8..72ddef2 100644
--- a/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerEmptySettingsTest.php
@@ -31,6 +31,13 @@ protected function setUp() {
   public function testInstaller() {
     $this->assertUrl('user/1');
     $this->assertResponse(200);
+
+    // Trigger a container rebuild by installing a module. This will break if
+    // the settings file lacks configuration required by the Drupal kernel.
+    $edit = array();
+    $edit['modules[Core][action][enable]'] = 'action';
+    $this->drupalPostForm('admin/modules', $edit, t('Install'));
+    $this->assertResponse(200);
   }
 
 }
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index e3e76ad..8702ab4 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -630,7 +630,7 @@
 /**
  * Load services definition file.
  */
-$settings['container_yamls'][] = __DIR__ . '/services.yml';
+$settings['container_yamls'][0] = __DIR__ . '/services.yml';
 
 /**
  * Override the default service container class.
diff --git a/sites/example.settings.local.php b/sites/example.settings.local.php
index 34b4e19..7e2367a 100644
--- a/sites/example.settings.local.php
+++ b/sites/example.settings.local.php
@@ -32,7 +32,7 @@
 /**
  * Enable local development services.
  */
-$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
+$settings['container_yamls'][0] = DRUPAL_ROOT . '/sites/development.services.yml';
 
 /**
  * Show all error messages, with backtrace information.
