Add a label to the Docker container

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.

2 Likes

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

1 Like

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.

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.

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.

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

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

Thanks for your documentation and help here!

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).

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

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?