We're deploying robots in various manufacturing companies and need a solution to run our Python code via Docker containers on-site. The main concern is the safety and intellectual property of our code, as clients will have access to the Docker images. Is there a way to ensure that users can interact with the endpoints without being able to view the underlying Python code?
5 Answers
You really can't fully hide your code if it's running on a server controlled by the client. Compiling to executables is an option, but technically skilled users could still reverse it. To genuinely protect your intellectual property, consider separating the client and server, where your server retains the code and the client interacts via an API instead.
You can obfuscate code to make it harder to reverse engineer, but ultimately, everything in the container can be accessed by the user. Tools like PyArmor are useful, but they'll only provide a surface-level protection. Remember, effective licensing and legal protections are usually more reliable.
Thanks a lot! Will definitely try PyArmor!
If you're dealing with clients in jurisdictions without strong copyright enforcement, then your concern might be overblown. In my experience with B2B environments, it's not common for companies to obsess over hiding code in Docker images, especially if you have solid NDA agreements in place. Still, if you want to make it harder to read, look into tools like PyArmor for obfuscation.
Thanks a lot, this helps and will definitely checkout PyArmor.
Another option is to rewrite Python code using Cython and compile it. This won't provide perfect security, but it will make it harder to get through. That said, even compiled code can be reverse-engineered if someone is determined enough.
Thanks a lot, will check out Cython!
You might want to consider having one of your own servers set up within the client's datacenter. This way, you maintain control over sensitive IP while still providing the service they need. It might be a bit expensive and requires extensive administration, but for crucial systems, it can be an effective route. I've seen large companies adopt this approach for highly sensitive operations.
That is super valuable, thanks a lot for this deep explanation!

Thanks a lot, will give this a try!