docker --环境变量制作模板

比如你现在有配置文件:decoder.conf

decoder.conf里面有两个配置项写的是:

THREAD_NUM:24

GPU_ID:0

现在你希望通过某个统一的配置来修改这些配置项,以免在部署的时候挨个去改动每个配置文件。

那么可以如下操作:

1.写一个统一配置文件config.conf

里面写:

export thread_num=24

export gpu_id=0

2.将decoder.conf复制为decoder.emplate

将decoder.template里面改为

THREAD_NUM:${thread_num}

GPU_ID:${gpu_id}

3.在命令行中输入:source config.conf

4.在命令行中输入:envsubst < decoder.conf.template > decoder.conf

如果只想替换THREAD_NUM,不想替换GPU_ID,那就在命令行输入:

envsubst '${THREAD_NUM}' < decoder.conf.template > decoder.conf

猜你喜欢

转载自www.cnblogs.com/kuku0223/p/9401977.html