Using Kali Linux Docker Images

To use the Kali Linux Docker image, we will do the following commands:

kali@kali:~$ docker pull docker.io/kalilinux/kali-rolling
kali@kali:~$
kali@kali:~$ docker run --tty --interactive kalilinux/kali-rolling
┌──(root㉿e4ae79503654)-[/]
└─#

┌──(root㉿e4ae79503654)-[/]
└─# exit
kali@kali:~$

Please note, that this does not allow for systemd functionality, which would allow access to items such as systemctl. There are ways to get systemd to work with Docker, however they include modifying the Dockerfile and docker run flags. At this time this will not be covered.

Please also note, all the images below do not come with the “default” metapackage. You will need to apt update && apt -y install kali-linux-headless.

To resume an exited container we will complete the following:

kali@kali:~$ docker container list --all
CONTAINER ID   IMAGE                    COMMAND       CREATED         STATUS                          PORTS     NAMES
d36922fa21e8   kalilinux/kali-rolling   "/bin/bash"   2 minutes ago   Exited (0) About a minute ago             lucid_heyrovsky
kali@kali:~$
kali@kali:~$ docker start d36922fa21e8
kali@kali:~$

After you execute the following command you will attach to the Docker container, however you must press return once to fully see the prompt:

kali@kali:~$ docker attach d36922fa21e8

┌──(root㉿d36922fa21e8)-[/]
└─#

This will resume the container in whatever state you left it after running the initial docker run command or the last docker start and docker attach sequence.

Finally, if you’re done with the container you can remove it with the following command:

kali@kali:~$ docker rm d36922fa21e8
d36922fa21e8
kali@kali:~$

Updated on: 2023-Jun-08
Author: gamb1t