How can one understand what is necessary for the DockerFile and Docker Compose file?

That’s why people learn for years so they can understand the documentation and use tutorials for more ideas so they can put the pieces together and solve their specific case. You can also hire a consultant.

I always say that Docker is not a magic wand. You need to learn about the operating system (Linux, Windows), the containerization concept in general, some knowledge about the kernel can help too.

So Docker is just a tool. If you know how to write a software that is well-organized and the components can communicate through the network, and you also know how to write a software that can be installed without user interaction, then you can use Docker to containerize it. The fact that Docker Desktop provides some ways to initialize a project (which was suggested by @meyay: How to create a Dockerfile and dockercompose.yml file - #2 by meyay) is nice, but that is just to start when you have no idea how to do that. how many containers you create is up to you. You could have everything in one container, which is absolutely not recommended, or have a container for each component which makes sense only if those components are individual entities an can communicate with eachother through the network or they don’t need to communicate.

Tutorials can focus on a specific goal and show you some useful features or show gneral ideas which is like learnig about multiplication, but it won’t tell you what is the result of 7876871312 multiplied by 976382676 ( typed random numbers).

I also have this message snippet to share recommended tutorials (including mine) to learn about the basics

Recommended links to learn the basics and concepts:

The last link is (currently) about Docker Desktop which is Docker CE in a virtual machine whith a GUI.