在docker-compose.yaml中使用环境变量设置布尔值可以通过以下步骤实现:
ENABLE_FEATURE
的环境变量,并将其设置为true
或false
。version: '3'
services:
myservice:
image: myimage
environment:
- ENABLE_FEATURE=true
version: '3'
services:
myservice:
image: myimage
environment:
- ENABLE_FEATURE=true
command: >
sh -c 'if [ "$ENABLE_FEATURE" = "true" ]; then
enable_feature_command;
else
disable_feature_command;
fi'
在上述示例中,根据ENABLE_FEATURE
环境变量的值,服务的命令将执行不同的操作。
请注意,以上答案仅供参考,具体的产品选择和配置取决于您的实际需求和偏好。
领取专属 10元无门槛券
手把手带您无忧上云