Following command will get just the name of the first Docker service running (usually the last one deployed) of a list of N services with running/shutdown/etc status.
Format name: service_name.N.ID
docker service ps my_service_name \
--no-trunc --format="{{.Name}}.{{.ID}}/{{.DesiredState}}" | grep "Running" | cut -f1 -d "/" | head -n1
# my_service_name.1.abcd1v23ui456pyu7lx8k9fzeMore details at https://docs.docker.com/engine/reference/commandline/service_ps/#formatting