docker-compose can’t set env values automatically
There is a start.sh
script under the application:
scripts/start.sh
#!/bin/bash
source /env/set.sh
env/set.sh content:
#!/bin/bash
export DB_USERNAME=a
export DB_PASSWORD=b
docker-compose.yml
version: '3.4'
services:
web:
build: .
expose:
- "5000"
command: scripts/start.sh
tty: true
stdin_open: true
After run docker-compose build && docker-compose up
, login into the container, the env values had not been set. But should run source /env/set.sh
manually.
Why didn’t command: scripts/start.sh
work?
Source: StackOverflow