Workaround to docker run “--env-file” supplied file not being evaluated as expected

后端 未结 6 1296
你的背包
你的背包 2021-02-05 23:58

My current setup for running a docker container is on the lines of this:

  1. I\'ve got a main.env file:
# Main
export PRIVATE_IP=\\`echo          


        
6条回答
  •  执笔经年
    2021-02-06 00:20

    What you can do is create a startup script that can be run when the container starts. So if your current docker file looks something like this

    From ...
    ...
    CMD command
    

    Change it to

    From ...
    ...
    ADD start.sh start.sh
    CMD ["start.sh"]
    

    In your start.sh script do the following:

    export PRIVATE_IP=\`echo localhost\`
    export MONGODB_HOST="$PRIVATE_IP"
    export MONGODB_URL="mongodb://$MONGODB_HOST:27017/development"
    command
    

提交回复
热议问题