Skip to main content
1-Visitor
August 26, 2016
Solved

Running ThingWorx in Docker

  • August 26, 2016
  • 4 replies
  • 9113 views

Does anybody here run ThingWorx 7.2 (preferably on Ubuntu) in docker? If so, can you please share your docker file for bulding such a machine?

I beileve it would be huge help for whole Developer Community​.

Thanks in advance.

4 replies

12-Amethyst
August 29, 2016

You can ask Marco Bratz from doubleslash. As far as I know they frequently use Docker. You can find him on xing.com

22-Sapphire I
August 29, 2016

The short answer I believe is yes .. .the long answer .... I'm seeing if someone in Dev wants to contribute to this, since I know we use Docker in Dev.

jgabriel1-VisitorAuthor
1-Visitor
August 30, 2016

Thanks for reply let me know, if something comes up. (please see my addition below).

jgabriel1-VisitorAuthor
1-Visitor
August 30, 2016

On second thought, for minimal image and overhead would be best to hook it up together from these two images based on alpine linux:

But still lacking experience though. 😃

jgabriel1-VisitorAuthor
1-Visitor
October 11, 2016

It is far from perfect and minimal, but it works, Posting it here, so anybody can learn from it and possibly improve it.


It should work, if you copy TW installation files into tw directory and run docker-compose up in root folder. After some initial setup, you should be able to see TW instance on your localhost/thingworx port 80.


File here: ThingWorx setup for docker.



1-Visitor
October 12, 2016

Thanks Jan,

This is very interesting, would you be so kind as to share your learning and the process you followed as well as the prerequisites?

Thank you,

Duan

1-Visitor
December 2, 2016

Just wanted to share my how to to build up a TW instance using docker.

Build an ubuntu server VM NIC bridged
Login

sudo apt-get update

Install OpenSSH server

sudo tasksel

Back up sshconfig
sudo cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config_backup

Edit the config file to allow port 22
sudo nano /etc/ssh/ssh_config

uncomment Port 22

restart ssh
sudo service ssh restart

Get server IP

ifconfig

Log in from putty

Install docker
wget -qO- http://get.docker.com | sh

Add your user to docker group
sudo usermod -aG docker (username)

exit

Log back in with putty.


Configure your docker directory


mkdir (docker working dir)

cd /(docker working dir)

mkdir build

Add your war file and tomcat-users.xml to the build directory. "filezilla"

nano Dockerfile

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

FROM java:8-jre

ENV CATALINA_HOME /usr/local/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
RUN mkdir -p "$CATALINA_HOME" \
&& mkdir -p "/ThingworxStorage" \
&& mkdir -p "/ThingworxBackupStorage"

# && chown tomcat8:tomcat8 /ThingworxStorage /ThingworxBackupStorage \
# && chown 755 /ThingworxStorage /ThingworxBackupStorage

WORKDIR $CATALINA_HOME

# see https://www.apache.org/dist/tomcat/tomcat-8/KEYS
RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys \
05AB33110949707C93A279E3D3EFE6B686867BA6 \
07E48665A34DCAFAE522E5E6266191C37C037D42 \
47309207D818FFD8DCD3F83F1931D684307A10A5 \
541FBE7D8F78B25E055DDEE13C370389288584E7 \
61B832AC2F1C5A90F0F9B00A1C506407564C17A3 \
713DA88BE50911535FE716F5208B0AB1D63011C7 \
79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED \
9BA44C2621385CB966EBA586F72C284D731FABEE \
A27677289986DB50844682F8ACB77FC2E86E29AC \
A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 \
DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 \
F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE \
F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23

ENV TOMCAT_MAJOR 8
ENV TOMCAT_VERSION 8.0.37
ENV TOMCAT_TGZ_URL https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz

RUN curl -SL "$TOMCAT_TGZ_URL" -o tomcat.tar.gz \
&& curl -SL "$TOMCAT_TGZ_URL.asc" -o tomcat.tar.gz.asc \
&& gpg --verify tomcat.tar.gz.asc \
&& tar -xvf tomcat.tar.gz --strip-components=1 \
&& rm bin/*.bat \
&& rm tomcat.tar.gz*

ENV JAVA_OPTS -Dserver -Dd64 -Xms1024m -Xmx5g -XX:+UseNUMA -XX:+UseConcMarkSweepGC
ENV CATALINA_OPTS -Djava.net.preferIPv4Stack=true

COPY build/tomcat-users.xml $CATALINA_HOME/conf/
COPY build/Thingworx.war $CATALINA_HOME/webapps/

EXPOSE 8080
CMD ["catalina.sh", "run"]

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Build docker

docker build -t thingworx .

Run, instance.
docker run -d -p 8080:8080 thingworx

Test connect to http://IP:8080/Thingworx

default account is Administrator/admin

You should use Docker shared volumes to get the TW storage directories (/ThingworxStorage and ThingworxBackupStorage) outside of the container. Example : docker run -d -p 8080:8080 -v $HOME/TW/ThingworxStorage:/ThingworxStorage -v $HOME/TW/ThingworxBackupStorage:/ThingworxBackupStorage thingworx