How to Deploy an Application to Docker

Official Content
This documentation is valid for:

Use the steps described in this article to easily deploy and run Java, .NET and .NET Core generated applications in a Docker Container.

Note that these steps help you to deploy the generated programs, not the database. To deploy the database refer to Export Reorganization. For further options refer to Application Deployment tool.

Software Requirements:

Steps to deploy to Docker

  1. Before you deploy your application for the first time to a specific target (eg.: production), we recommend creating a new environment in the Knowledge Base so that it
    • runs locally in the Tomcat or IIS of the computer used to work with GeneXus and
    • is connected to the target (eg.: production) database
  2. Build All
  3. Go to the Build menu and select the Application Deployment tool option
  4. In the Deployment screen:
    1. Select the Main objects to be included in the deployment
    2. In Target, select the option "Docker Image"
    3. Set the following properties as indicated below (All fields have default values):
      1. Docker base image property: The image that is used as a base to create the new one
      2. Maintainer name property: The name of the Author of the image; it's set as part of the metadata of the image
      3. Docker Environment variables property: All the environment variables you wish the image to have already instanced
      4. Image WebApp location property: The path inside the docker image where the application runs
      5. Docker image name property: The name of the generated docker image
  5. Click on the Deploy button to create the Docker Image

Now run the following command, in the Windows command prompt, to list the Docker images, including the one you created in the previous steps

docker images

Steps to run the Docker Image

Java

Java environments generate images based on Linux. To run a container based on the previously created image, execute the following command.

docker run --rm -p 9999:8080 <Docker image name>

where:

  • --rm indicates that the container is deleted once it is shut down
  • 9999:8080 indicates that the port 8080 (tomcat default) is exposed as 9999 on the host
  • <Docker image name> is the one created in the previous step

After successfully running this command, you can access the application's main object at http://localhost:9999/servlet/<Java package name>.<qualified object's name>.

C#

C# environments generate images based on Windows. To run a container based on the previously created image, execute the following command.

docker run --rm <Docker image name>

where:

  • --rm indicates that the container is deleted once it is shut down
  • <Docker image name> is the one created in the previous step

Note: After a while, an error will be shown in the output, but you can ignore it (.ref https://github.com/Microsoft/aspnet-docker/issues/69)

ERROR ( message:Cannot find requested collection element. )
Applied configuration changes to section "system.applicationHost/applicationPools" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"

The windows container does not run (virtually) on the same host. To get the IP where it runs, execute the following command.

docker ps

This shows a list of the running containers, displaying a CONTAINER ID.

To access the application's main object on that container, execute http://<CONTAINER ID>/<qualified object's name>.aspx

.NET Core

.NET Core environments generate images based on Linux. To run a container based on the previously created image, execute the following command.

docker run --rm -p 9999:80 <Docker image name>

where:

  • --rm indicates that the container is deleted once it is shut down
  • 9999:80 indicates that the port 80 (web default) is exposed as 9999 on the host
  • <Docker image name> is the one created in the previous step

After successfully running this command, you can access the application's main object at http://localhost:9999/<qualified object's name>.aspx.

Restrictions

  • Using default Docker base images
  • Deployment package (war) created in Java is compatible with Tomcat 8.x
  • Deployment package created in .NET is compatible with IIS 8 (or higher)

See Also

FAQ

1) I already have my own images where I want my apps to run. Can I deploy my app to those?

Yes, you can. You can change the default base image to be used by Genexus in the Docker base image property. There you can set your own image and the docker client will try to pull it from a registry if it's not available on your computer. Keep in mind that the image WebApp location property might also be necessary to be changed.


Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.