Docker Community Forums

Share and learn in the Docker community.

What user? title must be 15 characters long

I am trying to port my application over to docker. I am trying to figure out user management though.

What user do services run as? I would rather things not run as root, but cant seem to find much information online.

Do I need to create users in the containers? If so, what is the way to create shared user between all the containers?

As an example, say I have 3 different services that all touch the same files.

  1. Web (nginx)
  2. Queue Worker (supervisor)
  3. API Server (php, mostly)

Do I just chown to nobody? Do I chmod 777?

Do I need to create users in the containers? If so, what is the way to create shared user between all the containers?

If you want to run as a non-root user, you will need to create that user inside the containers. If you want to use a particular user id across multiple containers, the easiest solution is probably to create a base image that creates that user, and then build your application image on top of that.

Alternately, you can just run the appropriate adduser or useradd or whatever is appropriate as part of the build steps for each individual image.

Do I just chown to nobody? Do I chmod 777?

You probably don’t want to do either of these things. Either run your services as root, or arrange to create user and have files and directories owned by that user.