Declare env variable which value include space for docker/docker-compose

前端 未结 3 1428
清歌不尽
清歌不尽 2020-12-18 22:12

I have an env variable value like this:
TEST_VAR=The value

Do anybody knowns whether this is legal? should I place \" around the value

3条回答
  •  时光说笑
    2020-12-18 22:36

    Lets see the result running the following compose file:

    version: "3"
    
    services:
        service:
            image: alpine
            command: env
            env_file: env.conf
    

    env.conf:

    TEST_VAR1=The value
    TEST_VAR2="The value2"
    

    docker-compose up Result:

    service_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    service_1  | TEST_VAR2="The value2"
    service_1  | TEST_VAR1=The value
    service_1  | HOME=/root
    

    Therefore, it is legal to have spaces in the env value.

提交回复
热议问题