I’ve successfully pulled the Kali Linux Docker image and started a container, but now I’m running into a problem where the container won’t resume properly after I exit it. When I try to restart the container with docker start and then attach with docker attach, I get an error message stating that the container isn’t in the correct state, and the terminal becomes unresponsive. Here’s the exact sequence of commands and output:
kali@kali:~$ docker start d36922fa21e8
kali@kali:~$
kali@kali:~$ docker attach d36922fa21e8
I receive no prompt, and the terminal just hangs. I’ve also tried killing and restarting the container with the docker kill and docker rm commands, but I still encounter the same issue.
kali@kali:~$ docker kill d36922fa21e8
kali@kali:~$ docker rm d36922fa21e8
Additionally, I’m not sure how to enable systemd functionality to use systemctl within the container, as I’ve heard it’s possible but requires modifying the Dockerfile. I attempted to modify the Dockerfile as follows, but I keep running into issues:
FROM kalilinux/kali-rolling
RUN apt update && apt -y install kali-linux-headless
RUN systemctl enable docker.service
However, when I build the Docker image with this modification:
kali@kali:~$ docker build -t my-kali-image .
I receive the following error related to systemd not being able to run inside Docker:
Failed to connect to bus: No such file or directory
Can anyone guide me on how to fix the restart issue or help me enable systemd properly within the container? For more information on using Kali Linux Docker images, I’ve been following the official guide: view.kali.org/docs/containers/using-kali-docker-images/. Any help would be greatly appreciated!