Err: top-level object must be a mapping

You are making the same mistake as in the other topic

Talking about Docker Compose only when you actually use Docker Swam. In the other topic, the original issue at least was related to Docker Compose, but in this case you are using only docker stack commands that is part of Docker Swarm, and not Docker Compose, so I moved the topic to the Docker Swarm category to make it more obvious to everyone. Swarm just let’s you use the compose file syntax but there are differences as you already know.

As I suspected in the other topic as well, I’m still not sure the file you share is actually the one that your pipeline uses. Maybe your original file is changed somehow. You should try to run the commands in a local swarm cluster instead of hunting issues in a pipeline. If it works locally, then the problem is with the pipeline.

This for example:

Is an empty service. Where is the image from which the container has to be started? You should have had an error like this:

failed to create service test_db: Error response from daemon: rpc error: code = InvalidArgument desc = ContainerSpec: image reference must be provided

I guess you deleted the parts that seemed irrelevant, but you should remove only passwords keeping the original syntax or it could easily fix the original issue and there is no syntax error anymore in your shared compose file. I can’T even make the syntax wrong. It just runs on my machine. What is the Docker version? I could not find it in the other topic.