How to run Docker on Kali - kdaisho/Blog GitHub Wiki
Setting Up Docker in Kali Linux Using Nix
Steps to Run Docker in Kali:
-
Install Docker with Nix:
- Add
pkgs.docker_26to home.packages in home.nix
- Add
-
Configure
secure_pathinsudoers: This is needed as I installed the docker using nix which defaults to user-level installation, but docker has to run with sudoer privilege.- To ensure
sudocan access your Nix binaries, edit thesudoersfile usingvisudo:sudo visudo - Add
/home/kali/.nix-profile/bin/to thesecure_path:Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/kali/.nix-profile/bin"
- To ensure
-
Start the Docker Daemon:
- To run the Docker daemon (
dockerd), execute the following command:dockerd --host=unix:///var/run/docker.sock - This will start the Docker daemon and make it accessible through
/var/run/docker.sock.
- To run the Docker daemon (
-
Fix
docker.sockPermissions (if necessary--I didn't do this):- If you encounter permission errors for
docker.sock, you may need to change the permissions or add your user to thedockergroup:sudo usermod -aG docker $USER
- If you encounter permission errors for
-
Verify Docker Installation:
- After starting
dockerd, check the Docker installation with:docker ps
- After starting
-
Final Result:
- Docker should now be set up and ready to use. You can use Docker commands both with and without
sudo, depending on your configuration.
- Docker should now be set up and ready to use. You can use Docker commands both with and without
Future Notes:
- When using Nix for package management, binaries are located in
/home/kali/.nix-profile/bin/. Ensure thatsecure_pathis updated insudoersso thatsudocan find these binaries. - Always use
visudoto safely edit thesudoersfile to avoid breaking your system. - To run Docker as a non-root user, make sure you're added to the
dockergroup or use the rootless Docker setup.