Docker does not "host a project": it provides the possibility to specify an execution environment (Dockerfile and docker build) and to run it.
The "source" (Dockerfile and the resources like your project sources) don't have to be available at all: only the built image must be there in order to docker run it.
That image can be stored in a private registry (docker distribution), and it won't includes the sources of your projects, but only the deliveries (executable) built from those sources and installed in the image by the Dockerfile directives.
certain users may wish to access only one aspect of the product.
A simple solution is to have:
- several images (each one with a certain aspect of your product installed in it)
- several docker image registries (each one accessible to only a certain group of your clients, and including only the relevant image)
Kauê Oliveira asks in the comments the interesting question:
It doesn't prevent anyone from accessing the code once the container is running. You can sh in the container and do whatever you want
You would find a similar debate in "Does container image contains application source code?"
It depends on the application, of course:
- a compiled one can take advantage of a multi-stage build, and include only the executable
- an interpreted one could keep sources separated, but still visible and mounted through a volume (so the sources are still visible in the container, but not in the image).
From that thread:
The idea is that your container image has everything needed to run your application and nothing more (or at least as little more as possible).
For example, if you have a Java app, you don’t want to have to ship the full JDK, all build tools and plugins, etc. when, at the end of the day, you only need the final compiled Java code and a JRE.
It reduces your overall image size and your security footprint of the final running app.
And (using an application in PHP, arguably interpreted):
Why not pull the source in from GitHub? Store your credentials as env
variable. That way, any random person that pulls your image wont see your code, if that’s your concern
Honestly, though. PHP code doesn’t ever seem so complex that you’re at a loss as to how some function was done. If someone wants to steal your idea, they’re going to do that, regardless of how you try to make obfuscate it.