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

前端 未结 3 1441
清歌不尽
清歌不尽 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

    You can escape the space with a \:

    TEST_VAR=The\ value
    

    Edit: This is how I pass them when starting the container (i.e. docker run -e TEST_VAR=The\ value hello-world). If you're using docker-compose or an env file, see the answer by @yamenk.

提交回复
热议问题