Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Adding many Labels to Docker Containers quickly/efficently

Featured Replies

Hi,

 

I'm setting up Traefik (which I became used to running Ubuntu Server), but the question is more generic than that. I need to add ~5 Labels to many docker containers. Previously, when I was using Docker Compose to orchestrate things, this was a simple but attention-requiring Copy & Paste and replace the relevant bits. Through the UI I'm finding it more time consuming (although not impossible). I was wondering if there was a method or approach to speed up the task, at least as much as it can be.

 

Thanks

 

EDIT: Ok this really wasn't that bad in the end. A text editor with what I had to copy and paste speeded things up a lot and you can use Traefik with as little as 3 Labels. Also, contrary to my earlier confusion, I mean Labels, not Environment Variables.

Edited by hpka
Added retrospective.

  • 10 months later...

I am trying to also set up traefik and not grasbing labels yet in unRaid 

HEre is an example of labels I want to use in unraid 

 

# the basic labels to enable traefik to forward requests.somedns.com on port 443 to the ombi docker image
traefik.enable=true
traefik.http.routers.ombi.entrypoints=websecure
traefik.http.routers.ombi.rule=Host(`requests.somedns.com`)
# Specify the port your service should connect to (Optional if there is only one port)
traefik.http.services.ombi.loadbalancer.server.port=3579
# to tell traefik to try get a letsencrypt cert for your domain
traefik.http.routers.ombi.tls.certresolver=letsencrypt
#If you want to redirect port 80 to 443 when connecting to this domain on port 80
traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
traefik.http.routers.https-redirect.entrypoints=web
traefik.http.routers.https-redirect.middlewares=https-redirect
traefik.http.routers.https-redirect.rule=Host(`requests.somedns.com`)

 

I figured out how to add labels to the docker containers in unraid, is there a way to do it with out using the GUI ? want to apply to other containers with out manually adding around 7 lines per container 

  • 3 months later...
On 2/19/2020 at 2:50 AM, sstretchh said:

I figured out how to add labels to the docker containers in unraid, is there a way to do it with out using the GUI ? want to apply to other containers with out manually adding around 7 lines per container 

I don't believe there is.

 

The posts I have seen prefer the gui to be used to change the xml files, so I have added the traefik labels into configs in the dynamic traefik files instead.

 

it takes away some of the benefit of traefik, but it works.

  • 3 years later...

I would like to push this thread.

 

I am also in need to add a bunch of labels per container. Is there a way to do this in a file, and not in GUI?

  • 10 months later...
  • Community Expert

Also worth noting docker has an option to specify container labels via a file using the option --label-file. It can be specified in Dockerman's extra arguments field. 

On 7/29/2024 at 10:45 AM, primeval_god said:

Also worth noting docker has an option to specify container labels via a file using the option --label-file. It can be specified in Dockerman's extra arguments field. 

 

This makes it super convenient to add any number of predefined label groups. The issue with using it for Traefik labels is that you can't pre-define the label file with substitutions/variables, so it's not convenient to get the container's name into a label value.

 

On 7/29/2024 at 9:09 AM, phyzical said:

i created this plugin to solve this https://github.com/phyzical/docker.labelInjector

 

I gave this a quick test and notice that key.value pairs aren't saved, nor can they be pre-defined by the plugin. It also requires pairs to be entered one at a time and into two different fields, which makes editing a bit slow.

Maybe you can consider adding a configuration to the plugin where you can set up some defaults? And with variable substitution support so that the same defaults can easily be reused.  Example:


 

traefik.enable=true
traefik.http.routers.$containername.entryPoints=https
traefik.http.routers.$containername.rule=Host($containername.$TLD)
traefik.http.services.$containername.loadbalancer.server.port=$containerport

 

Edited by Espressomatic

  • 2 weeks later...

@Espressomaticthanks for the feedback, yeah i kinda just got it working for a simple case, did what i needed it to.

ive got to be honest the unraid under the hood isn't the nicest to play with, i spent alot longer trying to do the simple things that i lost alot of motivation to make it fancier :D

But im sure ill get some time at some point to make it more magic like your thinking

If i do
* yeah maybe a config that defines a list of variables that can be referenced

* list of defaults
* prefill with existing containers for selection/modification

  • 2 weeks later...

@Espressomatic Hey ended up needing to add more labels for other things, so i had to motivation to touch it up again.

it now has
* a better select field
* ability to add defaults to be prefilled each time via the settings page

* ability to provide ${CONTAINER_NAME} for auto replacement


The only thing i didnt do was prefilling with existing labels based on container selections as i felt it might just ends up being more annoying than useful

 

Edited by phyzical

Very nice, this is going to be a huge time-saver for anyone using Traefik with Unraid's default Docker apps.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.