rambv
(Rambv)
November 27, 2019, 1:24pm
1
Hi,
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.
meyay
(Metin Y.)
November 27, 2019, 9:37pm
2
If you use swarm stacks/services, you can add an environment variable and assign a template placeholder as value.
See:
Today I was playing around with mounting cifs shares into a container and figured I’d like to include the namespace to the mounted path. That made me play with the known swarm template variables (docker service create | Docker Documentation ).
I found the template command for X_SERVICE_LABEL_STACK_NAMESPACE usefull in my endover to have stack name specific mounts
Maybee this information is usefull to others as well. The stack is called ‘test’.
version: '3.7'
services:
ubuntu:
…
rambv
(Rambv)
November 28, 2019, 7:32am
3
Unfortunately I don’t use Swarm. Is there still a solution for me?