Addgroup: command not found with Docker image `nixos/nix:latest`

I am using the Docker image nixos/nix:latest for my GitLab CI/CD pipeline.

In my CI script, I use the command addgroup. My CI pipeline was working yesterday but since today (2021-12-15), it is broken with the error addgroup: command not found.

I can see that nixos/nix:latest has changed in the last 24 hours so I suspect it is the cause of my broken pipeline.

What is the right way to get access to addgroup with the new Docker image nixos/nix:latest?

I confirm that using explicit docker image nixos/nix:2.3.12 works and nixos/nix:2.5.0 fails.

@garbas you published the image nixos/nix:2.5.0, do you know what is going on?

Probably related to Use a pure Nix approach to building containers by adisbladis · Pull Request #31 · NixOS/docker · GitHub .
The 2.3.x images were based on Alpine. 2.5.x is built using the Nix docker tools.

Hey!

As @mausch mentioned docker imaged after 2.3.x are not based on any image and built with Nix.

There are few ways how you can add a group to the image. Which way you choose to go depends on your situation at hand.

  1. The most Nix way would be to extend the docker image from nix repository with Nix. And create groups and users as we do in docker.nix. Ofcourse this method requires you to know quite some Nix and how to do it.

  2. You can also just extend the docker image as you would usually do with Dockerfile, but use Nix to install all the utilities you need.

FROM nixos/nix

RUN nix-channel --update

RUN nix-env -iA nixpkgs.shadow

RUN groupadd veryspecialgroup ...

I hope this help you at least a bit.

1 Like