Set docker image username at container creation time?

后端 未结 3 1058
情话喂你
情话喂你 2021-02-07 09:10

I have an OpenSuse 42.3 docker image that I\'ve configured to run a code. The image has a single user(other than root) called \"myuser\" that I create during the initial Image g

3条回答
  •  长发绾君心
    2021-02-07 09:52

    First of all (https://docs.docker.com/engine/reference/builder/#arg):

    Warning: It is not recommended to use build-time variables for passing secrets like github keys, user credentials etc. Build-time variable values are visible to any user of the image with the docker history command.

    But if you still need to do this, read https://docs.docker.com/engine/reference/builder/#arg:

    A Dockerfile may include one or more ARG instructions. For example, the following is a valid Dockerfile:

    FROM busybox
    ARG user1
    ARG buildno
    ...
    

    and https://docs.docker.com/engine/reference/builder/#user:

    The USER instruction sets the user name (or UID) and optionally the user group (or GID) to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.

    USER [:] or
    USER [:]
    

提交回复
热议问题