My solution is to run the language server in a container created from the (almost) same image.
Step 1: From your “production” docker image, derive a “development” image that installs the language server.
Step 2: Write a docker-compose.yaml that defines a service that is based on the development image and mounts the project directory.
Step 3: In your .dir-locals.el for the project, configure Eglot to use docker-compose run --rm -w {mounted project root} {service name} {language server command line}
.
What I get is navigation through my project code, and documentation/completion over libraries. What I don’t get is navigation into libraries (because they exist only in the container and in this setup Emacs only deals with files on the host.)
I have also worked with a guy who mounted his PyCharm installation and config directories and the X11 socket and the /dev/dri device inside the container, and ran an instance of the IDE inside the development container. This gave him all the advantages of working directly with the project and libraries, but the disadvantage that the IDE is separated from the host.