声明env变量,该值包含用于docker / docker-compose的空间 [英] Declare env variable which value include space for docker/docker-compose

查看:104
本文介绍了声明env变量,该值包含用于docker / docker-compose的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的环境变量值:

TEST_VAR =该值

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

有人知道这是否合法吗?我应该在值上放置 以便在docker中根据需要进行解释吗?
谢谢

Do anybody knowns whether this is legal? should I place " around the value for this to be interpreted as needed in docker? Thanks

编辑:引号不是一个好的解决方案,因为它是val的一部分,请参见参考文献此处

EDIT: Quotation marks will not be a good solution as it is will be part of the val see reference here.

推荐答案

让我们看看运行以下撰写文件的结果:

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 结果:

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

因此,在env值中包含空格是合法的。

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

这篇关于声明env变量,该值包含用于docker / docker-compose的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆