Line-by-line code debugging inside a container
Before we dive into this section about debugging code running inside a container line by line, let me make a disclaimer. What you will learn in this section should usually be your last resort if nothing else works. Ideally, when following a test-driven approach when developing your application, the code is mostly guaranteed to work since you have written unit and integration tests for it and run them against your code, which also runs in a container. Alternatively, if unit or integration tests don’t provide you with enough insight and you need to debug your code line by line, you can do so by running your code directly on your host, thus leveraging the support of development environments such as VS Code, Eclipse, or IntelliJ, to name just a few IDEs.
With all this preparation, you should rarely need to manually debug your code as it is running inside a container. That said, let’s see how you can do it anyways!
In this...