Docker-alpine: Cannot switch into user created with adduser

Created on 29 Oct 2015  路  6Comments  路  Source: gliderlabs/docker-alpine

Need to be any other user than root to use abuild on alpine, can't figure out if there's a problem with adduser or me. When add a user like this adduser -D abuild get the following entry in /etc/passwd.

abuild:x:1000:10:Linux User,,,:/home/abuild::60:60:mysql:/var/lib/mysq

When switching into abuild get the following error.

su abuild
su: can't execute ':60:60:mysql:/var/lib/mysq': No such file or directory

Tried other variants. Creating system user with adduser -S doesn't add mysql bit, but then I can't switch into that user. Ideally I want to have a passwordless user, but when omitting -D and entering a password, it get's created without mysql but other things appended to the end, still can't su.

adduser baz
Changing password for baz
New password: 
Bad password: too short
Retype password: 
Password for baz changed by root
tail -n 1 /etc/passwd
baz:x:1001:1001:Linux User,,,:/home/baz:r
su baz
su: can't execute 'r': No such file or directory

Overall, entries for new users differ a lot from default entries in /etc/passwd. What's the deal with all that?

question

Most helpful comment

Just in case someone is still looking for this :

# docker run -ti alpine sh
/ # whoami
root
/ # adduser -D myUser
/ # su -l myUser
f3d9613b321d:~$ whoami
myUser

All 6 comments

@andyshinn has a great example at https://github.com/andyshinn/docker-alpine-abuild/blob/master/Dockerfile to set up a "builder" user for abuild. https://github.com/andyshinn/alpine-pkg-glibc completes the example to build a specific package.

i followed the same pattern for https://github.com/jumanjiman/alpine-pkg-openssl

hth

Hey Paul, saw your related issues and comments on the subject. The builder image looks exactly like what I need, thanks for that. Gonna give it a go.

Yep, the below works perfectly. Is adduser command acting as expected then? Shall this be closed?

adduser -G abuild -g "Alpine Package Builder" -s /bin/sh -D builder
echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

Keep in mind that builder image will likely change slightly in the next month or so. There are some changes in branch https://github.com/andyshinn/docker-alpine-abuild/tree/refactor_env_volumes so that you don't need a container per package and you just pipe the keys in via environment variables.

Will do. Thanks Andy.

Just in case someone is still looking for this :

# docker run -ti alpine sh
/ # whoami
root
/ # adduser -D myUser
/ # su -l myUser
f3d9613b321d:~$ whoami
myUser
Was this page helpful?
0 / 5 - 0 ratings