Skip to content
Discussion options

You must be logged in to vote

Uncloud doesn't automatically inject environment variables to service containers with the host IP or hostname values. But you can try injecting these values via binding a file from the host to the container.

First, create a file on the host, e.g. at /opt/uncloud/host_info:

HOST_IP=1.2.3.4
HOSTNAME=my-server

Then in your Compose file bind mount this file to the service container at /host_info:

services:
  myapp:
     ...
    volumes:
      - /opt/uncloud/host_info:/host_info

Then you can access /host_info from the process inside your container. You can also try changing the command that runs in the container to something like:

command: export $(cat /host_info | xargs) && start-app

In th…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mx1700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants