Issue
I'm trying to build a linux docker container with xrdp service installed so that I can remotely access the RDP service over not only the localhost interface but also the host network eth0 ip interface. I'm failing at understanding what I'm missing here with docker networking and properly launching the container. Docker running on Ubuntu Linux 20.04. As a test, when I run this docker command:
docker run --rm -d --network host --name my_nginx nginx
I observer that nginx is listening on port 80 and exposed on the localhost interface and I can access it with a browser. Verifying with:
sudo netstat -tulpn | grep 80
Now here is the linux container I'm trying to build and launch. I use a Dockerfile to launch an xrdp service.
FROM kalilinux/kali-rolling
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -y update && apt-get -y dist-upgrade && apt-get -y autoremove && apt-get install -y wget && apt-get clean
RUN apt-get -y install vim net-tools whois netcat exploitdb man-db dirb nikto wpscan uniscan nodejs npm python3-pip tor proxychains
RUN apt-get install xrdp lxde-core lxde tigervnc-standalone-server -y
COPY ./xrdp.ini /etc/xrdp/xrdp.ini
COPY ./Xwrapper.config /etc/X11/Xwrapper.config
RUN service xrdp start
ENTRYPOINT ["/bin/bash"]
Now I build the container and try to run it like this:
docker run --rm -d --network host --name my_kali kali
The container doesn't look like it runs and there is not a port 3389 listening on lo or eth0 interfaces. Now when I run the container another way, I can access the host with an RDP client over the Docker0 IP interface (172.17.0.2):
docker run -ti kali
But this only exposes the RDP service over Docker0 private network. The goal or use case is to build a container that can be accessed over eth0 interface of the host computer. The user can RDP into it and use the GUI to run tools. Any help appreciated on what I'm missing here.
Solution
Here was the resolution in Dockerfile:
CMD /usr/sbin/xrdp-sesman;/usr/sbin/xrdp -n
Then launched the image with -p:
docker run -d --name kali-image -p 3389:3389 kali
Verify port is listening:
docker port kali-image
Thanks to David Maze above.
Answered By - Jason Answer Checked By - Katrina (WPSolving Volunteer)