Hello,
First of all, a note about Docker and the like. This is a technique for bundling an application, including all its resources, into a single package and running it in an isolated environment. A lightweight alternative to a virtual machine. Unlike a virtual machine, however, this means that the host and Docker systems are equivalent to each other. Variants that also using the container principle, are chroot, flatpack and appimage. Qemu is an emulator like VMware and VirtualBox and can also run foreign operating systems, even those with completely different architectures, such as ARM. Before considering Docker, etc., you should consider the necessary requirements and the entire process behind OpenPLC.
Essentially, three independent parts are required. First, the editor, which creates an ST file regardless of the input method. Second, MATIEC (iec2c), which converts this into a C program along with some auxiliary files, and as the third and final step, a C compiler that generates the program for the target system. Depending on the target system, a small intermediate step and a HAL are required to adapt the various resources, such as IOs.
The last step is the most challenging. Is there a suitable compiler that meets at least the C99 standard? Can it be executed on the host platform running the OpenPLC Editor? And last but not least, is there suitable software or information for the hardware layer?
Once all of this is met, you can think about how to integrate it into a complete package, for example, a Docker image. Now to Qemu, which can be helpful if the compiler is only available for a very specific operating system or architecture. Depending on the case, full virtualization may be necessary, but simple userspace emulation is often sufficient. If all you need is an isolated environment with suitable libraries and tools, Docker is also a good choice.
To illustrate how this works and the associated problems, here's an example. The target platform is good old DOS, real-mode x86.
This doesn't work with the built-in tools on Windows 11, nor does it work on Linux. The first approach is a DOSBOX emulator and Borland C. The problem is that the C compiler doesn't understand some of the C constructs generated by MATIEC. An alternative from the retro scene, OpenWatcom, has the same problem. The GNU compiler is usually the best choice when it comes to standards compliance. After extensive research online, the ia16-gcc toolchain was chosen, which meets all the requirements. In many cases, however, there are no binary packages available, and the tools must be built from source. There are a few stumbling blocks. Often, the projects, and thus the source code, date back to a time when the target platform was still modern, so you have to use tools from that era for translation. For this, it's very useful to use older Debian versions on a virtual machine and, if possible, create static programs.
At the end, when all hurdles have been overcome and others are also supposed to participate in the hard work, it's time to put everything into a Docker image.
ST file in, binary runtime out!