How to add users to Docker container?

后端 未结 8 1188
无人及你
无人及你 2020-11-28 17:07

I have a docker container with some processes (uwsgi and celery) running inside. I want to create a celery user and a uwsgi user for these processes as well as a worker grou

8条回答
  •  有刺的猬
    2020-11-28 17:43

    Everyone has their personal favorite, and this is mine:

    RUN useradd --user-group --system --create-home --no-log-init app
    USER app
    

    Reference: man useradd

    The RUN line will add the user and group app:

    root@ef3e54b60048:/# id app
    uid=999(app) gid=999(app) groups=999(app)
    

    Use a more specific name than app if the image is to be reused as a base image. As an aside, include --shell /bin/bash if you really need.


    Partial credit: answer by Ryan M

提交回复
热议问题