Interactive shell for debugging with Plone 6 docker-compose: The wsgi equivalent of bin/instance debug

When needed to debug on a running site, we need two zope instances sharing a single zeo instance (or a single relstorage db):

services:
  client1:
    container_name: client1
    ports: [ "8081:8080" ]
    extends: { service: base }
    command: start
  debug:
    profiles: [ "debugging" ]
    container_name: debug
    command: console
    extends: { service: base }
  base:
    image: plone/server-dev:6.1.1 # tested also with plone/plone-classicui:6.1.1 and plone/plone-backend:6.1.1
    container_name: base
    restart: always
    command: pwd
    environment: { ZEO_ADDRESS: zeo:8100 }
    depends_on: [ zeo ]
  zeo:
    image: plone/plone-zeo:6.0.0
    container_name: zeo
    restart: always
    volumes: [ data:/data ]
    ports: [ "8100:8100" ]
volumes:
  data: {}

data is persisted in a volume. See docker volume ls. Both zope instances (client1 service and the the debug service) share them also after destroying the containers!

$ docker compose up -d

# the following is only necessary if not already in the volume
$ docker exec \
    -e SITE_ID="Plone" \
    zope ./docker-entrypoint.sh create-classic

$ docker compose run --rm debug

Please note that this configuration shares only the persisted data. But it has separated wsgi and(!) separated venv.
From a debuggin/inspecting perpective a Plone installation has three layers: wsgi, venv, data.
In the lingo of older Plone versions with Unified installer we had two clients on the wsgi layer that shared the same venv and the same data. And all three lived in the same machine. When working with containers we can have the tree layers distributed (and sometimes duplicated) in different containers.

When we need to debug in a running installation we need at least two wsgi instances. Recall that zconsole starts a wsgi instance! This implies that you cannot debug a running filestorage instance because the data file is locked. You need at a zeo or a relstorage installation. Otherwise (in a filestorage installation) you must stop the running wsgi instance to start the zconsole's wsgi. With zeo/relstorage you can start the zconsole because neither zeo nor relstorage block the data.