How can I expose the tunnel URL to a service in Docker Compose?
What steps have you taken to resolve the issue?
I want to open a tunnel to a service in my Docker Compose file, and inject that PUBLIC_URL into the service environment variables.
How can I export the tunnel URL from the tunnel and inject it into my web service?
Example docker-compose.yml file. Notice the PUBLIC_URL in the web service:
services:
tunnel:
image: cloudflare/cloudflared:latest
command: tunnel --url http://web:80
web:
build: ./Dockerfile
depends_on:
- tunnel
environment:
PUBLIC_URL: How to set this?
You can’t realistically do this. You should setup a custom domain (--hostname in that tunnel command format) and use that. You will need to register a domain.
I might potentially run this compose multiple times at once, on multiple environments, for multiple users. These environments are short-lived, so that is why the account-less should be okay.
I also want each environment to not use the same hostname, and so it does not seem to me that the --hostname is the solution (please correct me on this).
I could also start the tunnel from outside of the docker-compose, but I just really want it combined in one place.
Understod, but there isnt an easy/builtin way to do this so you will have to write some custom scripts/docker images to allow for it, which is too complex for me to advise on.