When I execute docker stack deploy, it creates 3 services:
traefik (provider file)
traefik (provider Docker)
whoami (provider file)
This is not what I want. I just want to specify port for traefik service which is defined in file, I don't want to create another service. How can I reference existing traefik service from labels section so that it wouldn't create new one?
I'm trying to do something similar to what is described in this topic and I was curious about the statement quoted above.
I've got an application consisting of multiple containers, all defined as http services. I also have one or a few containers that will need tcp services. My approach has been to use the dynamic config file to define all the services. My reasoning has been that I don't want to have the config done using labels in compose files, as I'd like the compose file(s) to be as clean as possible. Also, we will need to modify the host rules for different installations. Hence, I found it to be cleaner to have all the configuration in the dynamic file, since it seems like that is the purpose of that file.
I would greatly appreciate if you could shed some light on the above statement and maybe also comment on my strategy to provide routing/services for the application behind Traefik.
Thanks for the input @bluepuma77. That seems to make sense in your case. Our product is not SaaS, so it's a little harder (read impossible) for us to control each instance. Also, the customer might need/want to be able to modify the installation, both in terms of what services to run and the config of each. So, it seems better and safer to have fewer files to modify, as we need to write configuration tooling to make that possible and safe to do in a running instance.
What stumps me is that when I try to add the tcp router/service in the dynamic config file, it doesn't work. It's not until I add back docker as a provider and use labels that I can get it to work. But, then of course, I also can't find any examples of a config.yml that include both http and tcp sections. The official documentation only shows how to do it with labels. Or I'm somehow not finding the right docs.
The usual challenge is that TCP needs to use TLS/SSL to be routed and Traefik needs the cert to be able to decrypt the request. If Traefik does not have the cert or it’s plain TCP, then you can only use HostSNI(`*`) with a single service on that port.
Hi @bluepuma77, thanks for the input. I've been using HostSNI(*) in my testing and I finally got this to work (for the most part), using a dynamic config file, like config.yml. As noted in my original question/comment, for my use-case, I don't particularly care for or like to use labels, as that will "muddle" the structure of the application and mix in configs into my compose files. I need to keep those as clean as possible, reducing the need to modify anything in those and instead drive all settings into config files based on runtime configs. Hence, in my case it seems like a bad idea to use labels and carry those around and subsequently having to modify them for each installation. I see how that definitely could work in some situations, but not so much for what I'm working on.
Thanks again for your suggestions, as it helped me get on the right path.