Skip to content

Conversation

@ElsevierAlex
Copy link
Contributor

Stabilise Docker GID to Prevent Conflicts With Base System Services

This PR resolves an issue where the Docker group GID changes unpredictably between image builds. This instability causes failures in Docker-related operations, especially when using the image in containerised GitHub Actions workflows (runs_on: container).

Across recent GitHub Actions Runner image releases (e.g., 2.328.0 to 2.330.0), the GID assigned to the docker group has been inconsistent, landing somewhere in the 990–999 range.

Example

GH_RUNNER_VERSION=2.328.0
polkitd:x:997:
docker:x:996:runner
runner:x:121:

and with:
GH_RUNNER_VERSION=2.329.0
docker:x:999:runner
runner:x:121:


This GID drift breaks downstream images, the underlying cause is that several system services installed before Docker create groups that occupy the upper-range GIDs first. As a result, by the time the Docker package installs, the expected GID is already taken.

Common conflicting system groups include:

systemd-journal:x:999:
systemd-network:x:998:
polkitd:x:997:

To prevent future collisions, the PR pre-creates the docker group before any Docker-related installation occurs, assigning it a fixed, safe GID.

Docker group GID is now fixed at 500.

  • The 500–700 range is widely considered a safe zone for non-core service accounts
  • This ensures consistent behaviour across different base OS versions and avoids accidental overlap with systemd, polkit, or other system services.

Looking forward to hearing your feedback.



build/tools.sh Outdated
rm -rf /tmp/lfs.tar.gz "/tmp/git-lfs-${GIT_LFS_VERSION}"
}

function configure_docker_group_id() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go around here instead, no need to make it a function, just do groupadd -g "$(docker_group_id)" docker || :

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! Moving it to here, unfortunately, doesn't work. The Docker packages automatically create the docker group with GID 999 during install_tools_apt. We need to create it with GID 500 beforehand to prevent this.

getent group docker
docker:x:999:runner
groupadd -g 500  docker || :
groupadd: group 'docker' already exists

Copy link
Owner

@myoung34 myoung34 Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add it after

just before install_tools_apt and install_tools so that it exists before those run, just add a comment above such as # The docker group needs to run before installers or similar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Owner

@myoung34 myoung34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Owner

@myoung34 myoung34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last nit, if you'll modify

to have

group:
    runner:
        exists: true
        gid: 121
    docker:
        exists: true
        gid: 500

then the tests will verify that the group change works as expected

@myoung34 myoung34 merged commit 73c1f98 into myoung34:master Nov 24, 2025
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants