Self/service and stack metadata missing inside container


I deployed a custom set of services via a home-brew Catalog. I wanted to use the rancher metadata service to get information about the service and stack, however, I notice they’re missing. The only thing available is “host”. From within a container I can view this by using curl:

root@c01nhvd614:/opt# curl rancher-metadata/latest/self/

Any ideas? Thank you!

Have you taken a look at the docs?

Hi @denise. Yes, and according to the docs I should be able to hit self/service

Provides metadata on the service of the container that you are executing the command in

However, this isn’t available to me in my container. Is it because I’m running in host mode? This sentence is kinda confusing:

Using Rancher Compose, any service, that doesn’t have another networking mode (net) specified, is launched in the managed network.


Yes, metadata is based on the source-ip of the request… with host networking the source is the host, and there is no way to differentiate which container “self” is.

Thank you @vincent. Sorry for the question, but is there any way for me to start a container and bind it to the HOST IP when I’m not running in host mode? I would like the self metadata, but I also have a bunch of ports to expose, and they need to be bound to the host IP and not the internal one.


If you actually need net:host then no, but you can get info about the container (or service, etc) by name from the rest of metadata.

Managed network + normal port mapping makes ports available on the host’s public IP address(es), so you may be misunderstanding what net:host is for and not actually need it?

@vincent, it’s really only for one port - 53 (TCP/UDP). I am running a DNS server in one of my containers and I need port 53 to be exposed back to the machines. I tried to run the DNS servers on port 54 in my container, and then use a load balancer to setup a rule to forward 53 to 54, but the load balancer doesn’t support UDP. Any other ideas on how I could do this while running n the managed network? I’ve got port 53 mapped in my docker-compose.yml - both UDP and TCP.