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

后端 未结 6 1298
你的背包
你的背包 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:23

    I had this issue when using docker run in a separate run script run.sh file, since I wanted the credentials ADMIN_USER and ADMIN_PASSWORD to be accessible in the container, but not show up in the command.

    Following the other answers and passing a separate environment file with --env or --env-file didn't work for my image (though it worked for the Bash image). What worked was creating a separate env file...

    # env.list
    ADMIN_USER='username'
    ADMIN_PASSWORD='password'
    

    ...and sourcing it in the run script when launching the container:

    # run.sh
    source env.list
    docker run -d \
        -e ADMIN_USER=$INFLUXDB_ADMIN_USER \
        -e ADMIN_PASSWORD=$INFLUXDB_ADMIN_PASSWORD \
        image_repo/name:tag
    

提交回复
热议问题