CATTLE_AGENT_IP resets to docker bridge ip when running rancherserver

I want to run rancherserver in a container on the host.
It works when I set CATTLE_AGENT_IP to <HOST_IP>, however after some time it resets to docker bridge IP. What can I do to avoid this reset?

See below the corresponding FAQ entry:

Are the IPs of the hosts correct in the UI?

Every so often, the IP of the host will accidentally pick up the docker bridge IP instead of the actual IP. These are typically 172.17.42.1 or starting with 172.17.x.x. If this is the case, you need to re-register your host with the correct IP by explicitly setting the CATTLE_AGENT_IP environment variable in the docker run command.
$ sudo docker run -d -e CATTLE_AGENT_IP=<HOST_IP> --privileged
-v /var/run/docker.sock:/var/run/docker.sock
rancher/agent:v0.8.2 http://SERVER_IP:8080/v1/scripts/xxxx

I’m a bit confused at what you are trying to do.

The CATTLE_AGENT_IP environment variable only works when launching the rancher/agent command which is when you are adding a host into Rancher. You typically already have a rancher/server container running.

After the rancher/agent container is launched with the addition of -e CATTLE_AGENT_IP, it should never be reset to the docker bridge.