Skip to main content

Users in Docker

Add user and group in Docker

Difference between “adduser” and “useradd”

"useradd" is native binary compiled with the system "adduser" is a perl script which uses useradd binary in back-end. It is more user-friendly and interactive compared to back-end useradd. With "adduser" the system level users account when created puts a user directory in home for the system user where "useradd" does not.

For non-root users ids above 999 should be used.

Different distributions (and their flavours) might have different options:


debian info (also Ubuntu info, etc.)

-g or --gid
groupadd --gid GID <groupname>

-g or --gid; -u or --uid
useradd --gid GID --uid UID <username>

only --gid
addgroup --gid GID <groupname>

only --uid and --gid
adduser --gid GID --uid UID <username>


Alpine info, groupadd and useradd are not available

-g or --gid
addgroup -g GID <groupname>

only -g; -u or --uid
adduser -g GID -u UID <username>


Archlinux info - more info..., addgroup and adduser are not available

-g or --gid
groupadd --gid GID groupname

-g or --gid; -u or --uid
useradd --gid GID --uid UID username