Linux: Find out / display PUID and PGID

The PUID and PGID can be relevant for NFS shares and Docker containers. To determine the PUID (User ID) and PGID (Group ID) of the user under which Docker is running on a Linux system, proceed as follows:

1. Find out the user name of the Docker process

First you need to find out the user name of the process under which Docker is running. You can do this with the following command:

ps aux | grep dockerd

This command lists all processes related to dockerd. In the output, you will see a column indicating the user name under which the Docker daemon is running. This is normally root, but it can also be another user if Docker has been set up with special permissions.

2. Determine the user ID (PUID) and group ID (PGID)

Once you know the user name, you can find out the PUID and PGID with the following command:

id <username>

Replace <username> with the actual user name you found in the previous step.

Example: if Docker is running as root, enter:

id root

3. Understanding the output

The output of the id command looks something like this:

uid=0(root) gid=0(root) groups=0(root)
  • PUID (User ID) is the number after uid=.
  • PGID (Group ID) is the number after gid=.

In this example, both the PUID and the PGID are 0, which is typical for the root user.

Summary

  1. Find the user name under which Docker is running with ps aux | grep dockerd.
  2. Find out the PUID and PGID of this user with id <username>.
  3. The PUID is the user ID (uid=) and the PGID is the group ID (gid=).
See also  Nagios / NCPA Docker Check Script with Substates

This information is useful when you start Docker containers and need specific user and group assignments, for example to get file permissions right.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top