Testing with Docker
This guide is mainly aimed at developers who want to deploy the app within a Docker container. Throughout the guide, we will see how we can run and test the app behavior when containerized.
Before continuing here, we recommend reading the basic testing guide.
The only additional prerequisite to Ngrok and MongoDB (which we mention in the basic guide) is Docker Desktop. You can find a setup guide here.
Note
Please note that Docker Desktop is no longer free for large businesses.
Docker files
Each of our blueprints include a Dockerfile:
The Dockerfile contains instructions based on which Docker will build the images. No changes should be required to these files.
Configuring Mongo
Before proceeding to run the app from a Docker container, there are a few configuration changes needed for MongoDB.
Because a Linux Docker container can be considered as a VM, and communicating from your container to your host machine cannot be done through localhost, you need to allow MongoDB connections on your machine IP, so that the application from your container can connect to it from an "external" machine.
Warning
This might open your database to access from outside your machine if your firewall is not configured correctly or installed.
To configure your MongoDB follow these steps:
- Open CLI and run this command:
ipconfig - Copy the
IPv4 AddressIP address. Note - your IP can change depending on your network settings, and you might need to update it from time to time. - Go to your MongoDB
/binlocation (usually 'C:/Program Files/MongoDB/Server/<version>/bin'), openmongod.cfgas Administrator and add the copied address to thebindIpconfiguration setting. For example:... net: port: 27017 bindIp: 127.0.0.1, <copiedIPAddress> ... - Save
mongod.cfg - From Task Manager navigate to the Services tab and search for 'MongoDB'. Right click and select Restart. This is needed so that the previous changes take effect.
- Using the same IP address, edit the blueprint's Mongo configuration settings, as follows:
appsettings.jsonfor the .NET blueprint{ ... "MongoDb": { "Connection": "mongodb://<copiedIPAddress>:27017", "Name": "lc-blueprint-app" } }application.ymlfor the Java blueprint... spring: ... data: mongodb: ... uri: mongodb://<copiedIPAddress>:27017 ... ...
Running apps in containers
There may be many ways of running applications in Docker containers. Below is a suggestion for each of our blueprints (.NET and Java).
.NET blueprint
The .NET blueprint comes with Visual Studio Docker Support enabled. See Rws.LC.AppBlueprint.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
...
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
...
</Project>
To run the solution from a container, follow these steps:
Open Docker Desktop.
From Visual Studio, select the Docker option from the Run dropdown menu.

When running it for the first time, it may take a while to create the image.
Once it's done, the Containers window will open. Here you can see the details and the logs of your running containers.
You can also check the container logs in Docker Desktop.

Check that the application is running correctly by performing a
GETrequest to your descriptor endpoint. For example:GET http://localhost:5000/v1/descriptor
Java blueprint
For the Java blueprint, we are going to explicitly create a Docker image and run it with Docker Desktop. To achieve this, you need to:
Run the Maven
packagecommand, so you generate the.jarfile for the blueprint project.Make sure that the
.jarfile was generated in the/targetfolder. By default, it is calledlc-blueprint-app-1.0-SNAPSHOT.jar.Copy the
.jarfile into the same directory with theDockerfile>/src/main/docker.Build the Docker image by using the build command:
docker build --tag <image_name> <blueprint_location>/lc-blueprint-app-public/src/main/dockerOpen Docker Desktop and search for the image by the
<image_name>you previously set (java_bp in this example).Click RUN and bind the exposed ports to localhost, as follows:

Check that the application is running correctly by performing a
GETrequest to your descriptor endpoint. For example:GET http://localhost:5000/v1/descriptor