Use sudo inside Dockerfile (Alpine)

后端 未结 2 862
长情又很酷
长情又很酷 2021-01-08 00:40

I have this Dockerfile ...

FROM keymetrics/pm2:latest-alpine

RUN apk update && \\
    apk upgrade && \\
    apk add \\
       bash

COPY . .         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-08 01:25

    The su-exec can be used in alpine. Do add it the package, if not already available, add the following to your Dockerfile

    RUN apk add --no-cache su-exec
    

    Inside your scripts you'd run inside docker you can use the following to become another user:

    exec su-exec  
    

    Alternatively, you could add the more familiair sudo package while building your docker-file Add the following to your Dockerfile that's FROM alpine

    RUN set -ex && apk --no-cache add sudo
    

    After that you can use sudo

    sudo -u  
    

提交回复
热议问题