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_26
to home.packages in home.nix
- Add
-
Configure
secure_path
insudoers
: 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
sudo
can access your Nix binaries, edit thesudoers
file 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.sock
Permissions (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 thedocker
group: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_path
is updated insudoers
so thatsudo
can find these binaries. - Always use
visudo
to safely edit thesudoers
file to avoid breaking your system. - To run Docker as a non-root user, make sure you're added to the
docker
group or use the rootless Docker setup.