Dear All,
I am trying to add a user, and then set a password for the user in a
Dockerfile using node:8-alpine as base image, I am running the following
command, but when I run the container, the user has no password at the end:
#Add user
RUN ["adduser","-D","-s","/bin/bash", "admin"]
#Set pwd for user
#this is not working
RUN ["echo","admin:password","|", "chpasswd"]
So I am wondering what the best practice here. Thanks,
Gabor
Gabor Toth wrote:
> #Add user> > RUN ["adduser","-D","-s","/bin/bash", "admin"]> #Set pwd for user> > #this is not working> RUN ["echo","admin:password","|", "chpasswd"]
I am not an expert and have never used it, but the docs[0] show, that
you should just "RUN adduser -D -s /bin/bash admin" and
"RUN echo admin:password | chpasswd", i.e. no hard brackets.
[0]: https://docs.docker.com/engine/reference/builder/
--
caóc
---
Unsubscribe: alpine-user+unsubscribe@lists.alpinelinux.org
Help: alpine-user+help@lists.alpinelinux.org
---
The exec form of RUN does not invoke a shell itself, so neither the pipe
works nor the echo command. You need to add the sh as first parameters -
example (with bash) is in the quoted doc.
HTH
Rainer
Sent from phone, thus brief.
Cág <ca6c@bitmessage.ch> schrieb am Mo., 9. Apr. 2018, 16:40:
> Gabor Toth wrote:>> > #Add user> >> > RUN ["adduser","-D","-s","/bin/bash", "admin"]> > #Set pwd for user> >> > #this is not working> > RUN ["echo","admin:password","|", "chpasswd"]>> I am not an expert and have never used it, but the docs[0] show, that> you should just "RUN adduser -D -s /bin/bash admin" and> "RUN echo admin:password | chpasswd", i.e. no hard brackets.>> [0]: https://docs.docker.com/engine/reference/builder/>> --> caóc>>>> ---> Unsubscribe: alpine-user+unsubscribe@lists.alpinelinux.org> Help: alpine-user+help@lists.alpinelinux.org> --->>