Use docker on nixos

1 Why

If you are a developer, you will definitely need to use Docker at one time or another. If you are on nixos, you might have postponed this step for as long as I did, but time will come when you will want to do it in nixos also :) I actually would have lived happily without docker on nixos for longer, but I had to use act for testing out github actions locally, so Docker was it's prerequisite.

So let's see how I installed Docker on NixOS.

2 How

Actually it was easier than expected.

There is a great docs page -

The only things I did was:

# install docker
virtualisation.docker.enable = true;
users.extraGroups.docker.members = [ "nixos" ];

Did sudo nixos-rebuild switch, rebooted the system for group changes to take effect with sudo reboot, then after logging in once again, checked if my user belongs to docker group with groups, then finally checked the docker status inside my nixos sudo systemctl status docker. Tried to run docker images to see if docker commands are working.

When I saw that they do,I tried these steps of Docker test container creation.

When this worked also, I knew I am set and ready to work with Docker from inside of nixos.