This is a docker forum and your problem is related to PHP. You probably need to read some more docs…
BUT make sure rdkafka is well installed !
You are running container ans once in a console you are thus (from what I understand) installing the extension by hand.
Are you then running your php code in the exact same container ?
What you should understand when you installing things by hand in a container is it’s not permanent. When you’ll suit the container you’ll loose your manual changes.
To make installation persistent, it should be installed using a dockerfile (my previous link).