Building a Desktop Container to Run DevTest

Blog Post created by wooda20 Employee on Jan 17, 2018

Previous: Running DevTest Workstation in a Browser 


The first step towards having DevTest Workstation run within a browser is to create a remote desktop in which the environment can be run. To keep the footprint small this will be done in a Docker container.


For this we will use a CentOS base, into which we will add a Xfce 4 desktop, xrdp and the ssh utilities. DevTest workstation will be installed in the image and a shortcut added to the desktop.


In order to make the environment complete, a graphical editor and a web browser will also be included, thus reducing the need to use any additional systems. The file compression utilities zip and unzip are also included, as is telnet to enable basic connectivity checks. 


Since multiple daemons must run, some behind the scenes magic will be performed by Supervisord


One quick note - the use of RDP would normally imply that file transfer would enabled by default - this, however, is not true when running in a container since mounting the file system(s) via FUSE would break the container isolation model. For the time being, therefore, file transfer will take place via ssh/scp, at least unit we have Guacamole running.


The instructions for building the desktop environment are as follows:-


Create a working directory somewhere convenient - the name and the location are not important, but, for our purposes we shall call it WS. Within this directory, un-compress the contents of the attached zip archive (WS.zip).


Perform a DevTest Workstation install and choose the installation path of WS/DEVTEST. Only the workstation install should be performed here, and any specific customisation can be performed within this as appropriate for your environment


Within the WS folder add your MySQL connector jar if required. Here we will assume that the jar is called simply mysql-connector.jar.


Other files of note within this folder are


1. supervisord.conf, which contains the following


command=/usr/sbin/xrdp-sesman --nodaemon

command=/usr/sbin/xrdp -n

command=/usr/sbin/sshd -D

This is the control file that will ensure that the relevant daemons are run at container start

2. WS.dockerfile - this contains the following

# CENTOS with xrdp. Xfce4 and DevTest Workstation

FROM centos
RUN yum -y install epel-release && \
yum -y groupinstall "Xfce" && \
yum -y install xrdp supervisor firefox openssh-server openssh-clients mousepad zip unzip telnet && \
yum clean all; rm -rf /var/cache/yum && \
useradd -m -s /bin/bash devtest && \
echo "devtest:devtest" | /usr/sbin/chpasswd && \
echo "/bin/xfce4-session" > /home/devtest/.xsession && \
chmod +x /home/devtest/.xsession && \
mv /usr/libexec/xfce-polkit /usr/libexec/xfce-polkit.keep && \
mkdir -p /opt/devtest

ADD supervisord.conf /etc/supervisord.conf
ADD xrdp/* /etc/xrdp/

COPY DEVTEST/ /opt/devtest/

ADD mysql-connector.jar /opt/devtest/lib/shared/mysql-connector.jar

RUN mkdir -p /home/devtest/Desktop/ && \
/usr/bin/ssh-keygen -A && \
chown -R devtest:devtest /opt/devtest/examples && \
echo '[Desktop Entry]' > /home/devtest/Desktop/Workstation.desktop && \
echo 'Version=1.0' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'Type=Application' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'Name=Workstation' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'Comment=DevTest Workstation' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'Exec=/opt/devtest/bin/Workstation' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'Icon=/opt/devtest/.install4j/Workstation.png' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'Path=/home/devtest' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'Terminal=false' >> /home/devtest/Desktop/Workstation.desktop && \
echo 'StartupNotify=true' >> /home/devtest/Desktop/Workstation.desktop && \
chown devtest:devtest /home/devtest/Desktop/Workstation.desktop && \
chmod +x /home/devtest/Desktop/Workstation.desktop && \
echo "Port 222" >> /etc/ssh/sshd_config

CMD ["supervisord"]

EXPOSE 3389 222

3. The xrdp folder that contains the modified xrdp control files.


The root account is not enabled by default - un-comment the last line and add a '&& \' to the previous to enable this, changing the password to whatever suits your environment first. 

Also note that the ssh port is set to 222 - this is to avoid any conflicts with the host system should the port not be translated. 


Finally, there is a docker-compose.xml file that will start two instances of the workstation - this should be modified to suit your needs 

version: '3'


     context: .
     dockerfile: WS.dockerfile
   image: devtest/workstation:latest
   hostname: "WS-1"
     - 3389:3389
     - 222:222

   image: devtest/workstation:latest
   hostname: "WS-2"
     - 3390:3389
     - 223:222

Note here that the both the RDP port and the SSH port are published on different numbers in order to avoid conflicts. In a later post we will discuss service delivery, which will allow us to not use published ports in this way.


Until we connect via Guacamole, you should now have two remote desktops that can be accessed via Remote Desktop Connection on Windows, or FreeRDP on Linux/Mac/Windows. 


The next post in this short series will cover setting up Apache Guacamole and configuring it to connect to the desktop containers described here.