~alpine/users

4 4

[alpine-user] Docker add user pwd

Details
Message ID
<CANKXKxE5j_iQu8TiaXmsNd81joNg=8opQwbY5gSJYFZqYfRuRg@mail.gmail.com>
Sender timestamp
1523261397
DKIM signature
missing
Download raw message
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
Details
Message ID
<20180409143913.GA27510@alpine.my.domain>
In-Reply-To
<CANKXKxE5j_iQu8TiaXmsNd81joNg=8opQwbY5gSJYFZqYfRuRg@mail.gmail.com> (view parent)
Sender timestamp
1523284753
DKIM signature
missing
Download raw message
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
---
Rainer Gerhards <rgerhards@hq.adiscon.com>
Details
Message ID
<CADk+mPDynxO4S0YoscYLYCBAithsJ0xVYn6wBsFjJoArt6SaHA@mail.gmail.com>
In-Reply-To
<20180409143913.GA27510@alpine.my.domain> (view parent)
Sender timestamp
1523285257
DKIM signature
missing
Download raw message
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
> ---
>
>
Details
Message ID
<d8b765de-f5d0-d051-57d2-db3cc32a3f10@owasp.org>
In-Reply-To
<CANKXKxE5j_iQu8TiaXmsNd81joNg=8opQwbY5gSJYFZqYfRuRg@mail.gmail.com> (view parent)
Sender timestamp
1523295258
DKIM signature
missing
Download raw message
On 09.04.2018 10:09, Gabor Toth wrote:
> #this is not working
> RUN ["echo","admin:password","|", "chpasswd"]

try with /bin/echo


---
Unsubscribe:  alpine-user+unsubscribe@lists.alpinelinux.org
Help:         alpine-user+help@lists.alpinelinux.org
---
Details
Message ID
<CANKXKxH2FTHEZD86w8uee3WkKy94QgD3M8EjC+ZFOm2_r8RPvw@mail.gmail.com>
In-Reply-To
<d8b765de-f5d0-d051-57d2-db3cc32a3f10@owasp.org> (view parent)
Sender timestamp
1523309003
DKIM signature
missing
Download raw message
Thanks, resolved:RUN ["/bin/bash","-c","echo user:somepassword | chpasswd"]

2018-04-09 19:34 GMT+02:00 Achim <achim@owasp.org>:

> On 09.04.2018 10:09, Gabor Toth wrote:
> > #this is not working
> > RUN ["echo","admin:password","|", "chpasswd"]
>
> try with /bin/echo
>
>
> ---
> Unsubscribe:  alpine-user+unsubscribe@lists.alpinelinux.org
> Help:         alpine-user+help@lists.alpinelinux.org
> ---
>
>
Reply to thread Export thread (mbox)