Problem with encrypted Python backend code – database not working in Docker

Hi,
I’m practicing deploying a full-stack app using Docker – with a React frontend, a FastAPI backend (Python), and a MySQL database. I want to protect my backend code by encrypting it so that when I share the Docker image, others can’t see the source code inside the container.

When I encrypt the backend code, the frontend and backend seem to work fine, but the database connection fails or doesn’t work properly.

Also, is there any method to prevent someone from entering the container and accessing the code or files? I want to make sure that even if someone runs the container, they cannot view the backend code or sensitive data.

How can I fix the database issue while keeping the backend code secure? Is there a recommended way to protect source code and data in Docker containers?

Thanks in advance!

You are not the first to ask that question. Have you tried the forum search? It should find at least two or three discussions about it.

Short answer. no, you can not prevent people from entering a container, or downloading image layers and analyzing them.
Long answer: to be found through the forum search.

Okey, Thanks for your responce.