I recently was asked to convert an app running on Weblogic to a container running on Azure. As a base app, we used a war file based on Hawt.io.
And as a base container image, we chose to use Tomee , which is a Tomcat container with EE capabilities. Let’s start building our dockerfile.
Next, we need to indicate the CATALINA_HOME directory. This is the top directory we will copy all relevant files to.
We will start by copying a tomcat-users.xml and a context.xml file to the correct directories.
The tomcat-users.xml file indicates which users will have access to our app and to the management gui of our app. It looks like this:
The context.xml file indicates as well from which source you can access the Tomcat server. For ease of use we will allow everyone.
The war file we wanted to deploy also needed a couple of jar files, so they were added as well in the dockerfile.
Next we started copying the actual app.
Last step in the dockerfile is expose a port and run catalina.
With this docker file now done, we can build and run our docker container locally.
You can now connect to this running container on port 8080. You can connect with the tomcatadmin user that’s in the tomcat-users file. This will give you the Tomcat admin page.
You can click the ‘Manager App’ button. This will show you the apps running on your Tomcat server.
You can click the link of the SHawtio app. To get to the index.html, we added this to our link. This now shows the hawt.io start page.
Now that we have our container running locally, we can now push it up to Azure. First, we will try and run it as a Azure Container Image. In a next blog post, we will run it in Web apps on containers.
To begin, login to your azure account and create a new resource group.
You can now log in to this registry and get the name/url of the newly created registry. Copy this name, you will need it in the next steps.
We can now tag our docker image and push it to the newly created registry.
We can now create an Azure Container Instance. Since this needs a PSCredential, we need to convert our registrycredentials first.
This will output info on your newly created Azure Container Instance. After a while it will be in a ‘Succeeded’ ProvisioningState. You can check its’ state with the following command.
This will also give you the public IP address at which your container is running. Just as we did with localhost, we can browse to this IP-address, add 8080 as port number and watch the apps on the Tomcat instance.
In a next post, I will push this container in Web Apps on containers.