COBOL in Docker
The image
The community publishes GnuCOBOL images. Pull one once and you have a compiler in a clean room, with nothing installed on your machine:
docker pull olegkunitsyn/gnucobol
Compile in a container
Run the compiler inside the container. Mount the current directory so the compiler sees your source and writes the executable back to it:
docker run --rm -v "$PWD":/src olegkunitsyn/gnucobol cobc -x -free -o /src/hello /src/hello.cob
Mount your source
Keep your sources on the host and treat the container as a tool, like a compiler version pin. The same trick works in CI: pin the image tag, and every build compiles with the exact same compiler.
The code on this page was not run: it needs Docker, which is not installed in this environment.
Article author: Arthur Isaev