Skip to content
Advertisement

Using `groupadd` in Docker container

I’m using Ubuntu 14.04 Trusty Tahr, and a quick peek at /etc/group reveals

JavaScript

When I tried to add staff, I got an error message as I would expect (being that staff is already defined with gid 50).

JavaScript

The unexpected part is when I tried to add a user with the staff group.

JavaScript

What am I doing wrong here? It don’t believe it is Docker specific, but I just wanted to make mention in case it was important.

Advertisement

Answer

Your problem is the use of the --root argument. If you look at the useradd man page, you’ll note that --root specifies a chroot directory:

JavaScript

That means that when you pass --root projects, the useradd command will be looking for /projects/etc/passwd, /projects/etc/group, etc. Those don’t exist, which leads to the “does not exist” error.

I wonder if you actually meant --home-dir or --base-dir instead of --root?

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement