Deploy to Docker MSBuild task

Official Content
This documentation is valid for:

To deploy to Docker, there are MSBuild scripts to set up the package and build the Docker image.

Docker is an external target and, as for all external targets, the deployment is performed using the GitHub deployment targets solution. 

It is possible to set up a package with all the necessary files ready to build the Docker image, or do both—create the package and build the image.

That depends on the CI pipeline you need to define. If you do not have the Docker requirements to build the Docker image in the machine where the GeneXus application is built, you can just set up the package and move it to a location where you can run the Docker engine.

This document explains the separate steps to create the package and build the image. Consider that all these steps can be done inside GeneXus also using the Application Deployment tool


After having run the two basic MSBuild scripts, as described in Application Deployment MSBuild tasks (create deployment and create package), you can execute the following MSBuild scripts to have a Docker image built.

Create package

This step creates a package that is suitable for doing a Docker build and then a Docker run. By default, a context folder is created below the root directory of the DeploySource indicated as a property of the MSBuild. You can change it using the DeployDirectory property.

Note that the configuration of Kubernetes (K8S) is optional as well as Redis configuration.

MSBuild.exe  /ToolsVersion:4.0 "C:\Genexus\CreateCloudPackage.msbuild"
/p:GXDeployFileProject=<path to the .gxdproj file>


Then, the assembled package consists of:

  • Application binaries
  • Dockerfile

Specifically, in the case of NET Web and CMD app, the context directory contains the Dockerfile plus a temp directory containing the entire decompressed application.

When Kubernetes is activated, you will have, for example:


In the case of Java Web, you will have the .War file plus the Dockerfile. And for CMD apps, the context folder will contain the JAR file of the application, plus the Dockerfile and the Drivers directory will all the dependencies.


Therefore, if you copy that entire directory on any machine that has Docker daemon, you can build and run the image.

Build the Docker image

After you have set up the package, you can build and get a Docker image by executing the following MSBuild:

MSBuild.exe /ToolsVersion:4.0 "C:\Genexus\DeploymentTargets\Docker\deploy.msbuild" 
/p:CreateCloudPackage ="false"

In order to run the Docker image, you have to push it to a registry and run it using the docker run command.


For compatibility issues, the deploy.msbuild script under DeploymentTargets\Docker folder, can still be used to do both tasks (generate the package and build the docker image)
The CreateCloudPackage property is used for that purpose. If it's not assigned or it's true, the package will be created.
Only when it's false, the package is not created and only a build of the image is done (which should have been created in a previous step).


The division of the Docker deployment in two steps is supported since GeneXus 17 Upgrade 10