8 days ago I opened this issue. I’ve found the solution but I don’t know how to apply it the “NixOS way.”
The problem is that the Docker daemon is still running as root, as well as my containers:
$ docker ps
NAMES IMAGE STATUS PORTS
$ docker context list
NAME DESCRIPTION DOCKER ENDPOINT ERROR
default * Current DOCKER_HOST based configuration unix:///run/user/1000/docker.sock
Warning: DOCKER_HOST environment variable overrides the active context. To use a context, either set the global --context flag, or unset DOCKER_HOST environment variable.
$ unset DOCKER_HOST
$ docker ps
NAMES IMAGE STATUS PORTS
<containers listed correctly here>
$ docker context list
NAME DESCRIPTION DOCKER ENDPOINT ERROR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock
I suspect that this is a bug after changing from a rootfull to rootless Docker installation in configuration.nix.
The solution is to disable the system-wide Docker daemon:
$ sudo systemctl disable --now docker.service docker.socket
$ sudo rm /var/run/docker.sock
But how do I do this declaratively, in the way NixOS intended? Because:
$ sudo systemctl disable --now docker.service docker.socket
Failed to disable unit: File /etc/systemd/system/multi-user.target.wants/docker.service: Read-only file system
I am able to delete var/run/docker.sock
though.
Relevant parts of my configuration.nix:
{
environment.systemPackages = with pkgs; [
docker
];
virtualisation.docker = {
enable = true;
rootless = {
enable = true;
setSocketVariable = true;
};
};
}
How do I disable this service, considering that I don’t have Docker defined to be ran as root in my configuration.nix?