I was wondering if there is a way to use environment variables taken from the host where the container is deployed, instead of the ones taken from where the docker stack d
Yes, this works when you combine two concepts:
This would pull in the hostname to the ENV value of DUDE for each container to be the host that it's running on:
version: '3.4'
services:
nginx:
image: nginx
environment:
DUDE: "{{.Node.Hostname}}"
deploy:
replicas: 3