# Add a label to the Docker container

**URL:** https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254
**Category:** Sysadmins
**Tags:** docker, how-to
**Created:** [June 17, 2022, 6:40am UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254 "2022-06-17T06:40:05Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Grunskin](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Grunskin](https://meta.discourse.org/u/Grunskin)
#### Post date: [June 17, 2022, 6:40am UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/1 "2022-06-17T06:40:05Z")

</div>

Just as I was writing a post asking how to add a label to a discourse container I figured it out so I thought I would share here so people my find it easier when googling.

I wanted to add a label to my discourse container so Watchtower wouldn’t try to update it every time.

I just overlooked the help that the `launcher` script printed and didn’t notice the `--docker-args`

To add the label I wanted I had to start it with the following:

```
./launcher start app --docker-args "--label com.centurylinklabs.watchtower.enable=false"

```

I had been googling and looking around for over a day and couldn’t find anyone that wanted to do the same thing so I thought I would post this and hopefully someone will find it useful.

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [June 17, 2022, 12:59pm UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/2 "2022-06-17T12:59:13Z")

</div>

To make it process more permanent in nature, you could add the docker args into the app.yml file as described in this traefik example

> [@Discourse with Traefik 2.0](https://meta.discourse.org/t/discourse-with-traefik-2-0/130357/2):
>
> After some trying I could solve it by my own. For further notice I attach my app.yml: ... templates: - "templates/postgres.template.yml" - "templates/redis.template.yml" - "templates/web.template.yml" - "templates/web.ratelimited.template.yml" ## Uncomment these two lines if you wish to add Lets Encrypt (https) #- "templates/web.ssl.template.yml" #- "templates/web.letsencrypt.ssl.template.yml" #- "templates/web.socketed.template.yml" ## which TCP/IP ports should this container…

---

<div class="post-metadata">

### Author: ![vawaver](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vawaver/32/387248_2.png) [@vawaver](https://meta.discourse.org/u/vawaver)
#### Post date: [May 20, 2024, 9:32am UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/3 "2024-05-20T09:32:37Z")

</div>

Greetings,

I’m currently using Watchtower to monitor and update my Docker containers in Portainer. However, I want to exclude the Discourse container from being updated by Watchtower.  
I am not IT pro so I want to ask you for a short tutorial on what exactly I must change in my Watchtower Monitor `docker-compose.yml` file and other changes in the Discourse configuration.  
I am glad for any help.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 20, 2024, 10:13am UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/4 "2024-05-20T10:13:31Z")

</div>

You can add a `labels:` stanza to your `app.yml` to include docker labels on the discourse container when it is started by launcher. Alternately, you can use `./launcher start-command app` to see the docker start command and then use whatever you want to use those same ENV variables to start the Discourse container.

You don’t say what Watchtower wants or needs to exclude Discourser from Watchtower, so I can’t tell you any more.

---

<div class="post-metadata">

### Author: ![vawaver](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vawaver/32/387248_2.png) [@vawaver](https://meta.discourse.org/u/vawaver)
#### Post date: [May 20, 2024, 5:06pm UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/5 "2024-05-20T17:06:15Z")

</div>

After thinking about it, I realized that the Docker image for Discourse is not tagged as `latest`. If I’m thinking correctly, Watchtower should be able to detect a newer version of the Discourse Docker image.

Please correct me if I’m wrong.

---

<div class="post-metadata">

### Author: ![ikarus84](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ikarus84/32/63601_2.png) [@ikarus84](https://meta.discourse.org/u/ikarus84)
#### Post date: [May 22, 2024, 7:22am UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/6 "2024-05-22T07:22:02Z")

</div>

To make it really simple: I added this in the app.yml

```plaintext
# any extra arguments for Docker?
docker_args:
  - "--label com.centurylinklabs.watchtower.enable=false"

```

Thanks for your documentation and help here!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 22, 2024, 9:31am UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/7 "2024-05-22T09:31:50Z")

</div>

Using the labels stanza applies the labels only to the running container while the docker-args way includes the labels on containers while they are bootstrapping (I’m fairly certain).

---

<div class="post-metadata">

### Author: ![ikarus84](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ikarus84/32/63601_2.png) [@ikarus84](https://meta.discourse.org/u/ikarus84)
#### Post date: [May 22, 2024, 6:19pm UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/8 "2024-05-22T18:19:23Z")

</div>

How would the complete stanza look like (for copy-pasting)?

---

<div class="post-metadata">

### Author: ![vawaver](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vawaver/32/387248_2.png) [@vawaver](https://meta.discourse.org/u/vawaver)
#### Post date: [May 23, 2024, 7:03pm UTC](https://meta.discourse.org/t/add-a-label-to-the-docker-container/230254/9 "2024-05-23T19:03:37Z")

</div>

So I let it run its course. Watchtower updated all other containers except Discourse. Although it showed an error, nothing was broken.  
@ikarus84 Have you managed to figure out how to set it up correctly to prevent these errors from occurring?
