# Labels in Docker file not being used

**URL:** <https://forums.suse.com/t/labels-in-docker-file-not-being-used/10849>\
**Category:** Rancher 1.x\
**Created:** [June 20, 2018, 8:16pm UTC](https://forums.suse.com/t/labels-in-docker-file-not-being-used/10849 "2018-06-20T20:16:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NigelGreenway](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NigelGreenway](https://forums.suse.com/u/NigelGreenway)\
**Post date:** [June 20, 2018, 8:16pm UTC](https://forums.suse.com/t/labels-in-docker-file-not-being-used/10849/1 "2018-06-20T20:16:06Z")

</div>

I’ve create my pipeline and all works fine. On push I have them pipeline:

Run tests  
Build docker image  
Push docker image to private registery  
Tell rancher there is an image  
rancher will then pull the image

Up to here is fine, but I need to go and add the labels into the container via the UI even though these have been added at the time of building the Docker image…

When I inspect the container on the host ie the labels.

Does rancher not see the labels? Can I get a container on the host, via rancher without any manual leg work?

---

<div class="post-metadata">

**Author:** ![JohnDavidLarsen](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@JohnDavidLarsen](https://forums.suse.com/u/JohnDavidLarsen)\
**Post date:** [June 20, 2018, 8:51pm UTC](https://forums.suse.com/t/labels-in-docker-file-not-being-used/10849/2 "2018-06-20T20:51:22Z")

</div>

Yes/No  
What are you trying to do with the labels?  
It seems the labels built into the image work just fine for scheduling and other programmatic needs. Though yes, you can’t see the labels inside the rancher UI.

Interestingly enough, containers launched through docker run command line seem to have the labels in the docker UI.  
You might want to submit this as a bug/feature request.

---

<div class="post-metadata">

**Author:** ![NigelGreenway](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NigelGreenway](https://forums.suse.com/u/NigelGreenway)\
**Post date:** [June 21, 2018, 7:51am UTC](https://forums.suse.com/t/labels-in-docker-file-not-being-used/10849/3 "2018-06-21T07:51:39Z")

</div>

@JohnDavidLarsen So, I’m trying to achieve the following:

```auto
LABEL traefik.frontend.rule=Host:$URL
LABEL traefik.backend=$CONTAINER_NAME
LABEL traefik.enable=true
LABEL traefik.port=3000

```

I then pass them variables via the build job. As soon as I add the labels manually via the Rancher UI I am able to see my containers show up in Traefik.

This obviously does not allow me to have complete automated deployment for my containers, so spinning up review containers on the fly without having to add further config for it to work is a bit of a blocker for using Rancher in this use case. ☹

---

<div class="post-metadata">

**Author:** ![JohnDavidLarsen](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@JohnDavidLarsen](https://forums.suse.com/u/JohnDavidLarsen)\
**Post date:** [June 21, 2018, 12:05pm UTC](https://forums.suse.com/t/labels-in-docker-file-not-being-used/10849/4 "2018-06-21T12:05:05Z")

</div>

Yeah, you can’t use variables in your Dockerfile

Anything done with the rancher UI can be done with the API (and in fact is done with the API).  
[https://rancher.com/docs/rancher/v1.6/en/api/v2-beta/api-resources/service/](https://rancher.com/docs/rancher/v1.6/en/api/v2-beta/api-resources/service/)

You may want to use your browsers developer tools and watch the network when you manually create a service in your stack, and record exactly what it is sending to the api. Then you can replay that yourself via your script. You need to setup API keys for that.

---

<div class="post-metadata">

**Author:** ![NigelGreenway](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@NigelGreenway](https://forums.suse.com/u/NigelGreenway)\
**Post date:** [June 21, 2018, 11:08pm UTC](https://forums.suse.com/t/labels-in-docker-file-not-being-used/10849/5 "2018-06-21T23:08:35Z")

</div>

@JohnDavidLarsen thank you very much for the heads up on the API. For some reason I never thought about hitting that. After playing with it tonight it does **exactly** what I wanted so a big thank you!

I’ve also contributed to [cdrx/rancher-gitlab-deploy](http://github.com/cdrx/rancher-gitlab-deploy) which adds a feature of passing labels (although I’ve never written Python before 😬 )
