Home > other >  Docker - container stack services dynamic host name
Docker - container stack services dynamic host name

Time:09-21

I'm from the Docker Cloud migration to pure Docker Swarm Settings. One thing I missed is the container how to set the hostname to $SERVICE_NAME - a good way to $SLOT_NUMBER.
Whether can be set in group a stack service dynamic host name/container name?

CodePudding user response:

In the stack/write file, use the following format:

Services:
Thaservice:
...
The hostname: "{{. Service. The Name}} - {{. Task. The Slot}}"

Link to the available template variables document: https://docs.docker.com/engine/swarm/services/#create-services-using-templates

CodePudding user response:

Brother solution not the problem
  • Related