Hi! I'm a newbie and trying to understand traefik. I have been playing around with their default example as a docker container. In there we're running a whoami service just to demonstrate stuff works. And both the traefik dashboard and the whoami service runs fine. I can even access it on whoami.localhost.
However when I move out my whoami service to its own folder and docker-compose.yml the service is no longer accessible on whoami.localhost and I'd like to understand why that is?
Thank you so much for pointing me in the right direction! This solved my problem.
I had been trying to figure out the network part for a while, thought it had something to do with it. I created an external network and solved it like this in both my compose files:
Alternatively you can setup the network in your Traefik docker-compose.yml, but give it a fixed name so it’s independent of compose and always has the same name:
Thanks! I believe I did something equivalent, but outside the docker-compose: docker network create traefik
However, with your method I don't have to remember to actually create the network since the compose file will set it up for me. I will consider this. Cheers!
One thing that bugs me though is that this set-up I've done now works fine on my server. But it is no longer accessible from within my local network. I'm thinking if it has anything with the way I set up my docker network? I can see all my containers within the network I've created.
Can you explain what is not working? You can only interact with containers when you are in a container yourself, that is attached to the Docker network.
There is an attachable option for overlay networks which can be set to true to attach other containers that don't belong to a service or a stack defined in the same file, but I think it's only relevant when using Docker Swarm.
I'm sorry if I was being unclear, I'll try explaining.
While my Traefik Dashboard is accessible throughout my local network on it's ip: http://192.168.1.249:8080/dashboard/ my other services only get a server local ip, that I can't reach from another computer in the network. If that makes sense?
I'm not familiar with all the docker/traefik terminology so perhaps I'm not using the right wording.
All my services are accessible on my server. But not from other devices on the network. As is shown in the json above with my docker network inspect of the network the containers are there.
I feel like I'm rambling. Hopefully something makes sense.
Your routing is done via domain/hostname (like whoami.localhost).
If you want to use that from another computer, you have to make sure that domain/hostname resolves to the correct IP. Either you enter something into your local hosts file or you setup your local DSL router with those DNS entries.
Alternatively you can setup an external DNS server and let a domain point to your local private IP. It will just not be available from outside your network.
I solved this by running my server on a VPN with a dedicated IP address. I then assigned a domain name to the IP that is resolved by traefik. Works like a charm!