Trying to run older ESPHome docker, platformio grief

I run ESPHome in the official docker container on my Ubuntu desktop. To try to troubleshoot a vexing issue with one of my configs, I’m trying to run an older version of the ESPHome container and built my config there. I’m hitting an issue related to the platformio version.

There must be something in my environment that is befuddling me, but I can’t see what it is. I used to run ESPHome natively installed, but AFAICT I’ve gotten rid of all remnants of platformio outside of the container. Suggestions?

If I use my usual ESPHome config directory mapped into the container, I get this stack trace when I try to build my config:

INFO Reading configuration /config/waterbug32.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing waterbug32 (board: lolin32; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
Error: Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/platformio/__main__.py", line 121, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/platformio/commands/__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/platformio/commands/run/command.py", line 134, in cli
    process_env(
  File "/usr/local/lib/python3.9/dist-packages/platformio/commands/run/command.py", line 176, in process_env
    result = {"env": name, "duration": time(), "succeeded": ep.process()}
  File "/usr/local/lib/python3.9/dist-packages/platformio/commands/run/processor.py", line 67, in process
    result = init_platform(self.options["platform"]).run(
  File "/usr/local/lib/python3.9/dist-packages/platformio/commands/platform.py", line 322, in init_platform
    return PlatformFactory.new(name)
  File "/usr/local/lib/python3.9/dist-packages/platformio/platform/factory.py", line 52, in new
    pkg = PlatformPackageManager().get_package(pkg_or_spec)
  File "/usr/local/lib/python3.9/dist-packages/platformio/package/manager/base.py", line 236, in get_package
    for pkg in self.get_installed():
  File "/usr/local/lib/python3.9/dist-packages/platformio/package/manager/base.py", line 209, in get_installed
    pkg = PackageItem(pkg_dir)
  File "/usr/local/lib/python3.9/dist-packages/platformio/package/meta.py", line 405, in __init__
    self.metadata = self.load_meta()
  File "/usr/local/lib/python3.9/dist-packages/platformio/package/meta.py", line 440, in load_meta
    return PackageMetaData.load(manifest_path)
  File "/usr/local/lib/python3.9/dist-packages/platformio/package/meta.py", line 393, in load
    data["spec"] = PackageSpec(**data["spec"])
TypeError: __init__() got an unexpected keyword argument 'uri'

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

If I get rid of the “.esphome” directory, I get this error message instead:

INFO Reading configuration /config/waterbug32.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing waterbug32 (board: lolin32; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
Platform Manager: Installing platformio/espressif32 @ 3.5.0
Error: Please upgrade to the PlatformIO Core 6