Docker compose - set container name and hostname dynamicaly

Hi,

Is there anyway to set the container name and hostname dynamically?

For example:

services:
syslog:
image: localhost/mysyslog:1.0
volumes:
- logs:/var/log
- cfg:/etc/rsyslog.d
deploy:
mode: replicated
replicas: 2
endpoint_mode: vip

If i start this service the containers will be named
syslog_syslog_1
syslog_syslog_2

Lets say i would like that the both the container names and the hostname of each container to be:
syslog1
syslog2

how could i achieve this?

While Docker Compose doesn’t allow template placeholders, Docker Swarm does.