Different Ways of Building a Native COBOL Application in a Container

Note: This topic only applies to using native COBOL applications 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.

When working with native COBOL applications in containers you need to be aware of the different methods in which the application can be built when debugging or running it. This topic describes the two methods that are available.

The two different methods and the effects of using each are as follows:

  • Build on host, also known as "fast mode" debugging or running

    The Dockerfile that Visual COBOL creates uses multi-stage builds - the "build" stage builds the project while the "base" stage copies the build output to the c:\App folder in the container's file system and then executes the project.

    Using the "build on host" method results in the project being built using only the "base" stage of the Dockerfile, which means that the project is built not with the development environment in the container, but with the development environment on the host. Once the build has taken place on the host, the folder containing the build output is volume mounted to the c:\App folder in the container file system.

  • Build in container

    Using the "build in container" method results in the project being built using the whole Dockerfile. This means that the project source files are copied into the container, they are then built by the development environment in the container, and the build output is then run using the deployment environment in the container.

The "build on host" method can be significantly faster than "build in container" because building a project on your host computer is typically faster than building it in a container, so the "build on host" method is used whenever you debug your native COBOL application.

The "build in container" method, although slower than the "build on host" method, will always use the same build, debug and deployment environment; that is, the environment included in the container. Because of these factors, the "build on host" method is used when you build a native COBOL application for release.

Note:

Both "build on host" and "build in container" methods result in Visual COBOL creating a container for the debug or run operation then removing the container once the project finishes its execution. Both methods also create an image which are kept and used for subsequent builds.