Thursday, 9 June 2022

Using Templates in Docker Container


sudo docker service create --name host_tmpl --hostname="{{.Node.Hostname}}-{{.Node.ID}}-{{.Service.Name}}" busybox top

716zlz66vpjeiri8jlwo1om2r

overall progress: 1 out of 1 tasks 

1/1: running   [==================================================>] 

verify: Service converged 


sudo docker service ps host_tmpl

ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS

wc27p53k3wop        host_tmpl.1         busybox:latest      ip-172-31-8-58      Running             Running 3 minutes ago  


sudo docker inspect wc27p53k3wop --format "{{json .Status}}"

{"Timestamp":"2022-06-09T19:21:48.969891614Z","State":"running","Message":"started","ContainerStatus":{"ContainerID":"932c467ad3158b3e4b52cb7e4ebd00601926f1a90b67b512d2bf428c0cb3f546","PID":11408,"ExitCode":0},"PortStatus":{}}


No comments:

Post a Comment