# Defaultrule, double container name

**URL:** <https://community.traefik.io/t/defaultrule-double-container-name/1714>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [September 19, 2019, 3:11am UTC](https://community.traefik.io/t/defaultrule-double-container-name/1714 "2019-09-19T03:11:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wesselingronald](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/wesselingronald/32/726_2.png) [@wesselingronald](https://community.traefik.io/u/wesselingronald)\
**Post date:** [September 19, 2019, 3:11am UTC](https://community.traefik.io/t/defaultrule-double-container-name/1714/1 "2019-09-19T03:11:10Z")

</div>

this is my traefik docker-compose.yml file

```auto
version: "3.5"
services:
  traefikv2:
    container_name: traefikv2
    image: traefik:latest
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --api.dashboard=true
      - --api.insecure=true
      - --providers.docker=true
      - --global.sendAnonymousUsage=true
      - --providers.docker.defaultrule=Host(`{{ .Name }}.redacted.nl`)
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    environment:
      - TZ=europe/amsterdam
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /docker/traefik:/storage
    networks:
      - test
    restart: always

networks:
  test:
    name: test

```

this is my portainer docker-compose.yml file

```auto
version: '3.5'

services:
  portainer:
    container_name: portainer
    image: portainer/portainer
    volumes:
      - /docker/portainer:/data
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro
    environment:
      - TZ=europe/amsterdam
    networks:
      - test
    restart: always

networks:
  test:
    name: test

```

Every container gets reversed proxied with the default rule.  
However, the name, is like portainer-portainer.redacted.nl or traefikv2\_traefik.redacted.nl

somehow, the stack gets prepended in the Name variable.

Is there a variable available with just containername, or some smart regex which fixes this ?  
i just want "portainer.redacted.nl"

in version 1.7 i had the same thing, and created a hostrule per docker-compose file.  
With this new system, i was hoping to automate this with a default rule.

I have seen the documentation, but only the Name or Label variable is mentioned. I wouldn't know on how to create a GO template

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [September 19, 2019, 9:26am UTC](https://community.traefik.io/t/defaultrule-double-container-name/1714/2 "2019-09-19T09:26:52Z")

</div>

Hello,

You can use the labels created by Docker it-self, by example:

```auto
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --api.insecure=true
      - --providers.docker=true
      - --global.sendAnonymousUsage=true
      - '--providers.docker.defaultrule=Host(`{{ index .Labels "com.docker.compose.service" }}.redacted.nl`)'

```
