Alias ​​service environment var in Docker container

I use Docker Compose to deploy containers. I have RethinkDB service container, which provides (inter alia) the host port in the following var the env: APP_RETHINKDB_1_PORT_28015_TCP_ADDR.

However, my application should get this host as env var with the name RETHINKDB_HOST.

My question is: how can I assign the given env var to what I want when starting the container (preferably on most dockers)? I tried:

env_file: .env
environment:
  - RETHINKDB_HOST=$APP_RETHINKDB_1_PORT_28015_TCP_ADDR

but firstly, it does not work, and secondly, it does not look as if it is the best way.

+4
source share
2 answers

, , . ,

ubuntu:
    links:
        rethinkdb:rethinkdb 

ubuntu ping rethinkdb IP-. RETHINKDB_HOST=rethinkdb. , , , , script CMD.

CMD, command: service rethink start, , , , .

command: sh -c 'RETHINKDB_HOST=$APP_RETHINKDB_1_PORT_28015_TCP_ADDR && service rethink start'

, startup script,

0

APP_RETHINKDB_1_PORT_28015_TCP_ADDR, , . " ". ,

environment:
  - RETHINKDB_HOST=28015
0

All Articles