To add a Dockerfile to a native COBOL project

Note: This topic only applies to using native COBOL applications and native Unit Test projects in containers. To use .NET COBOL applications in containers you need to use the functionality described in Debugging and Running .NET COBOL Applications in Containers.

Visual COBOL lets you add a Dockerfile to a native COBOL project or to a native Unit Test project to simplify the process of containerizing an existing application. The Dockerfile created by Visual COBOL uses default values for details such as image names and includes basic instructions in order to create an image for the native COBOL project. If you need the Dockerfile to use non-default settings or to perform additional processing you can modify it once Visual COBOL has added it to your project.

Note: As part of the Dockerfile creation process you can specify that the Dockerfile is to include commands to configure an enterprise server, the details of which are specified in an XML file that was created either by the casesxml import/export utility or from Server Explorer.

See casesxml for more information on the casesxml command, To export an enterprise server instance for information on using Server Explorer to export an enterprise server definition, and To add files to a COBOL project for information on adding a file to your project.

  1. Right-click your project in Solution Explorer and click Add > COBOL Docker Support.
  2. If the current project is an Enterprise Server Application project, the Create Enterprise Server for container dialog box is displayed.

    Select one of the following, then click OK:

    • Use associated server to specify that the generated Dockerfile is to include commands to configure the enterprise server that is associated with the current project. Selecting this option runs the casesxml import/export utility for the relevant enterprise server.

      This option is not available for selection if the current project does not have an enterprise server associated with it.

    • Create new server to specify that the generated Dockerfile is to include commands to configure an enterprise server based on an XML file. Specify a name to use for imported enterprise server then browse to and select the XML file.

    A Docker.deploy folder is added to the project. This folder contains the enterprise server definition and a PowerShell script named DeployAndWait.ps1 which is used to deploy the enterprise server and run it in the container.

  3. The Dockerfile is created, added to the project, and a Docker debug profile is created.

    If the project already contained a Dockerfile you are asked if you want to rename it and generate a new Dockerfile. Click Yes to rename the existing Dockerfile (to Dockerfile.original) or No to leave the existing Dockerfile unchanged.

Note:
  • If you need to modify the Dockerfile created by Visual COBOL, Micro Focus recommends that you maintain the same structure that is used by the one created by Visual COBOL. In particular, you should not change any of the stage names in order to preserve the way in which the Dockerfile is built.

    You might want to look at some of the Dockerfiles supplied with the Visual COBOL container demonstrations for guidance on the sort of changes to make.

  • Although it is possible to create a Dockerfile and manually add it to a native COBOL project Micro Focus recommends that you use the Add > COBOL Docker Support option in order to ensure that your development environment is correctly configured for working with containers.
  • In the Add COBOL Docker Support dialog box, the versions of the Runtime Image and the Built Tools Image must match therefore the dialog box only shows the Built Tools Images that match the one for the runtime. For example, if you use a Patch Update 1 Build Tools image, the dialog box only shows the relevant Patch Update 1 Runtime image. The images must target the same platform (x64 or x86) as well. If you want to specify images from different major product versions, you need to edit the Dockerfile manually.