How to get the service name from inside the container


I’ve got some debugging code that runs inside all of our containers, and it needs to understand which service it’s running in. Is there a way to know the service name of the container that you’re currently in? That is, completely from the inside without consulting the host.

Thanks for your help,
Ram Rachum.

If you use swarm stacks/services, you can add an environment variable and assign a template placeholder as value.


Unfortunately I don’t use Swarm. Is there still a solution for me?