Reputation: 1254
I came across a scenario where I need to build a docker image which needs to run as a non-root user. To explain in detail, during docker build, I am trying to install a service which needs to be installed as non-root user. So i looked around some like Link and Link which shows how to run a Docker container as non-root user. I am little confused on how to create a user in Dockerfile. I have used the below lines in dockerfile,
RUN useradd -r -u 1001 -g appuser appuser
USER appuser
I have successfully created the image and the container seems to be started as the appuser. But I need to provide this docker image to clients, so my question is,
Thanks in advance.
Upvotes: 0
Views: 948
Reputation: 1425
Do I need to create the user appuser on my client machines?
The RUN command isn't creating it on your client machine, it's creating it on the container. In fact all instructions in your Dockerfile apply to the image being build and the container launched from it.
How docker behaves in the client machine if I don't create any such users?
Same answer. Nothing is being installed on the client machine (apart from docker, which I assume is a given).
Upvotes: 1