Docker Compose website unable to find DB by service name

I am migrating several docker containers to my new Portainer installation. For the single instance containers all works well. But for stacks where I previouly used docker compose to start several services, the services do not seem to be able to find each other.

For example I have a .net core website that uses MS SQL Server. Both are linux images. The connection string in the website uses the service name in the docker-compose.yaml file. On a basic docker installation on Ubuntu works well. However on this new Portainer Stack installation, I rceive error messages from the website that it is unable to locate the SQL server service instance.

I am sure something as essential as this must work, so I guess I am doing something wrong. But I have spent an entire day searching the internet and documentation, but cannot find what.

I am not sure it is relevant as I am completely new to Portainer, but our installation is behind a DirectAdmin installation. I used the instructions here https://kb.yourwebhoster.eu/knowledge-base/how-to-use-docker-with-portainer-and-directadmin-without-ssh-access/ and this works great for accessing single containers.

Any and all help is greatly apreciated.

If both containers are in the same stack file, then there is probably an issue with the config of this. Feel free to post here and I can review

If one is outside the container network created when deploying the compose stack you could probably solve this by attaching it to the compose network.

If you are trying to access from the host this thread may help you