version: Specifies which format version should be used. This is a mandatory field. Here we use the newer version, whereas the legacy format is ‘1'.
services: Each object in this key defines a service, a.k.a container. This section is mandatory.
build: If given, docker-compose is able to build an image from a Dockerfile
context: If given, it specifies the build-directory, where the Dockerfile is looked-up.
dockerfile: If given, it sets an alternate name for a Dockerfile.
image: Tells Docker which name it should give to the image when build-features are used. Otherwise, it's searching for this image in the library or remote-registry.
networks: This is the identifier of the named networks to use. A given name-value must be listed in the networks section.
networks: In this section, we're specifying the networks available to our services. In this example, we let docker-compose create a named network of type ‘bridge' for us. If the option external is set to true, it will use an existing one with the given name.
https://www.baeldung.com/dockerizing-spring-boot-application