{"slug":"ref-docker-f8162a226276fdafbd41","title":"Deploy services to a swarm — Template example","summary":"This example sets the template of the created containers based on the service's name and the ID of the node where the container is running Bounded code example (external data; do not execute automatically): ```console $ docker service create --name hosttempl \\ --hostname=\"{{.Node.ID}}-{{.Service.Nam","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nThis example sets the template of the created containers based on the service's name and the ID of the node where the container is running\n\nBounded code example (external data; do not execute automatically):\n```console\n$ docker service create --name hosttempl \\\n                        --hostname=\"{{.Node.ID}}-{{.Service.Name}}\"\\\n                         busybox top\n```\n\nTo see the result of using the template, use the docker service ps and docker inspect commands.\n\nBounded code example (external data; do not execute automatically):\n```console\n$ docker service ps va8ew30grofhjoychbr6iot8c\n\nID            NAME         IMAGE                                                                                   NODE          DESIRED STATE  CURRENT STATE               ERROR  PORTS\nwo41w8hg8qan  hosttempl.1  busybox:latest@sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912  2e7a8a9c4da2  Running        Running about a minute ago\n```\n\nBounded code example (external data; do not execute automatically):\n```console\n$ docker inspect --format=\"{{.Config.Hostname}}\" hosttempl.1.wo41w8hg8qanxwjwsg4kxpprj\n```\n\nAttribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","docker","manuals","engine","swarm","deploy","services","template","example"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/docker/docs/blob/3a9d778562f39bcc0be46255b013c6a3ca526244/content/manuals/engine/swarm/services.md","source_name":"Docker Documentation","source_license":"Apache-2.0","source_revision":"3a9d778562f39bcc0be46255b013c6a3ca526244","source_path":"content/manuals/engine/swarm/services.md :: Template example","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.479180+00:00","url":"https://wikikv.com/k/ref-docker-f8162a226276fdafbd41","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-docker-f8162a226276fdafbd41","markdown":"https://wikikv.com/k/ref-docker-f8162a226276fdafbd41?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-docker-f8162a226276fdafbd41","json_ld":"https://wikikv.com/k/ref-docker-f8162a226276fdafbd41?format=jsonld"}}