diff --git a/core/core.services.yml b/core/core.services.yml
index f767c313f0..31d82faf4d 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -150,10 +150,10 @@ services:
       - { name: cache.context }
   cache_context.route.menu_active_trails:
     class: Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext
-    calls:
-      - [setContainer, ['@service_container']]
+    arguments: ['@menu.active_trail']
     tags:
       - { name: cache.context }
+    lazy: true
 
   # Complex cache contexts, that may be calculated from a combination of
   # multiple aspects of the request context plus additional logic. Hence they
diff --git a/core/lib/Drupal/Core/Cache/Context/MenuActiveTrailsCacheContext.php b/core/lib/Drupal/Core/Cache/Context/MenuActiveTrailsCacheContext.php
index db31384122..b05e2ac098 100644
--- a/core/lib/Drupal/Core/Cache/Context/MenuActiveTrailsCacheContext.php
+++ b/core/lib/Drupal/Core/Cache/Context/MenuActiveTrailsCacheContext.php
@@ -3,18 +3,25 @@
 namespace Drupal\Core\Cache\Context;
 
 use Drupal\Core\Cache\CacheableMetadata;
-use Symfony\Component\DependencyInjection\ContainerAwareInterface;
-use Symfony\Component\DependencyInjection\ContainerAwareTrait;
+use Drupal\Core\Menu\MenuActiveTrail;
 
 /**
  * Defines the MenuActiveTrailsCacheContext service.
- *
- * This class is container-aware to avoid initializing the 'menu.active_trails'
- * service (and its dependencies) when it is not necessary.
  */
-class MenuActiveTrailsCacheContext implements CalculatedCacheContextInterface, ContainerAwareInterface {
+class MenuActiveTrailsCacheContext implements CalculatedCacheContextInterface {
 
-  use ContainerAwareTrait;
+  /**
+   * Constructs a new MenuActiveTrailsCacheContext service.
+   *
+   * @var \Drupal\Core\Menu\MenuActiveTrail|null $menuActiveTrail
+   *   The active menu trail service.
+   */
+  public function __construct(protected ?MenuActiveTrail $menuActiveTrail = NULL) {
+    if ($this->menuActiveTrail === NULL) {
+      @trigger_error('Calling ' . __METHOD__ . ' without the $menuActiveTrail argument is deprecated in drupal:10.2.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/666', E_USER_DEPRECATED);
+      $this->menuActiveTrail = \Drupal::service('menu.active_trail');
+    }
+  }
 
   /**
    * {@inheritdoc}
@@ -31,8 +38,7 @@ public function getContext($menu_name = NULL) {
       throw new \LogicException('No menu name provided for menu.active_trails cache context.');
     }
 
-    $active_trail = $this->container->get('menu.active_trail')
-      ->getActiveTrailIds($menu_name);
+    $active_trail = $this->menuActiveTrail->getActiveTrailIds($menu_name);
     return 'menu_trail.' . $menu_name . '|' . implode('|', $active_trail);
   }
 
diff --git a/core/lib/Drupal/Core/ProxyClass/Cache/Context/MenuActiveTrailsCacheContext.php b/core/lib/Drupal/Core/ProxyClass/Cache/Context/MenuActiveTrailsCacheContext.php
new file mode 100644
index 0000000000..0f2d1302ba
--- /dev/null
+++ b/core/lib/Drupal/Core/ProxyClass/Cache/Context/MenuActiveTrailsCacheContext.php
@@ -0,0 +1,96 @@
+<?php
+// phpcs:ignoreFile
+
+/**
+ * This file was generated via php core/scripts/generate-proxy-class.php 'Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext' "core/lib/Drupal/Core".
+ */
+
+namespace Drupal\Core\ProxyClass\Cache\Context {
+
+    /**
+     * Provides a proxy class for \Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext.
+     *
+     * @see \Drupal\Component\ProxyBuilder
+     */
+    class MenuActiveTrailsCacheContext implements \Drupal\Core\Cache\Context\CalculatedCacheContextInterface
+    {
+
+        use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
+
+        /**
+         * The id of the original proxied service.
+         *
+         * @var string
+         */
+        protected $drupalProxyOriginalServiceId;
+
+        /**
+         * The real proxied service, after it was lazy loaded.
+         *
+         * @var \Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext
+         */
+        protected $service;
+
+        /**
+         * The service container.
+         *
+         * @var \Symfony\Component\DependencyInjection\ContainerInterface
+         */
+        protected $container;
+
+        /**
+         * Constructs a ProxyClass Drupal proxy object.
+         *
+         * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
+         *   The container.
+         * @param string $drupal_proxy_original_service_id
+         *   The service ID of the original service.
+         */
+        public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id)
+        {
+            $this->container = $container;
+            $this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id;
+        }
+
+        /**
+         * Lazy loads the real service from the container.
+         *
+         * @return object
+         *   Returns the constructed real service.
+         */
+        protected function lazyLoadItself()
+        {
+            if (!isset($this->service)) {
+                $this->service = $this->container->get($this->drupalProxyOriginalServiceId);
+            }
+
+            return $this->service;
+        }
+
+        /**
+         * {@inheritdoc}
+         */
+        public static function getLabel()
+        {
+          return t("Active menu trail");
+        }
+
+        /**
+         * {@inheritdoc}
+         */
+        public function getContext($menu_name = NULL)
+        {
+            return $this->lazyLoadItself()->getContext($menu_name);
+        }
+
+        /**
+         * {@inheritdoc}
+         */
+        public function getCacheableMetadata($menu_name = NULL)
+        {
+            return $this->lazyLoadItself()->getCacheableMetadata($menu_name);
+        }
+
+    }
+
+}
diff --git a/core/modules/book/book.services.yml b/core/modules/book/book.services.yml
index 780a6bffa4..95d18f704e 100644
--- a/core/modules/book/book.services.yml
+++ b/core/modules/book/book.services.yml
@@ -29,12 +29,10 @@ services:
       - { name: access_check, applies_to: _access_book_removable }
   cache_context.route.book_navigation:
     class: Drupal\book\Cache\BookNavigationCacheContext
-    arguments: ['@current_route_match']
-    calls:
-      - [setContainer, ['@service_container']]
+    arguments: ['@current_route_match', '@book.manager']
     tags:
       - { name: cache.context}
-
+    lazy: true
   book.uninstall_validator:
     class: Drupal\book\BookUninstallValidator
     tags:
diff --git a/core/modules/book/src/Cache/BookNavigationCacheContext.php b/core/modules/book/src/Cache/BookNavigationCacheContext.php
index 1611dd5690..93e5cbcfbb 100644
--- a/core/modules/book/src/Cache/BookNavigationCacheContext.php
+++ b/core/modules/book/src/Cache/BookNavigationCacheContext.php
@@ -2,12 +2,11 @@
 
 namespace Drupal\book\Cache;
 
+use Drupal\book\BookManagerInterface;
 use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Cache\Context\CacheContextInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\node\NodeInterface;
-use Symfony\Component\DependencyInjection\ContainerAwareInterface;
-use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 
 /**
  * Defines the book navigation cache context service.
@@ -17,13 +16,8 @@
  * This allows for book navigation location-aware caching. It depends on:
  * - whether the current route represents a book node at all
  * - and if so, where in the book hierarchy we are
- *
- * This class is container-aware to avoid initializing the 'book.manager'
- * service when it is not necessary.
  */
-class BookNavigationCacheContext implements CacheContextInterface, ContainerAwareInterface {
-
-  use ContainerAwareTrait;
+class BookNavigationCacheContext implements CacheContextInterface {
 
   /**
    * The current route match.
@@ -35,11 +29,17 @@ class BookNavigationCacheContext implements CacheContextInterface, ContainerAwar
   /**
    * Constructs a new BookNavigationCacheContext service.
    *
-   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
+   * @var \Drupal\Core\Routing\RouteMatchInterface $route_match
    *   The current route match.
+   * @var \Drupal\book\BookManagerInterface|null $bookManager
+   *   Book Manager Service.
    */
-  public function __construct(RouteMatchInterface $route_match) {
+  public function __construct(RouteMatchInterface $route_match, protected ?BookManagerInterface $bookManager = NULL) {
     $this->routeMatch = $route_match;
+    if ($this->bookManager === NULL) {
+      @trigger_error('Calling ' . __METHOD__ . ' without the $bookManager argument is deprecated in drupal:10.2.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/666', E_USER_DEPRECATED);
+      $this->bookManager = \Drupal::service('book.manager');
+    }
   }
 
   /**
@@ -66,7 +66,7 @@ public function getContext() {
     }
 
     // If we're looking at a book node, get the trail for that node.
-    $active_trail = $this->container->get('book.manager')
+    $active_trail = $this->bookManager
       ->getActiveTrailIds($node->book['bid'], $node->book);
     return implode('|', $active_trail);
   }
