docker-compose.yaml 环境变量
时间: 2023-09-10 08:14:04 浏览: 133
docker-compose yml配置lnmt环境
Docker Compose允许我们在docker-compose.yml文件中设置环境变量。在docker-compose.yml文件中,可以使用.env文件来定义环境变量。比如,在.env文件中定义了REDIS_PASSWORD=ABC123这个环境变量,然后在docker-compose.yml文件中可以通过$REDIS_PASSWORD来引用这个环境变量。例如,可以这样设置REDIS_PASSWORD环境变量:
```
services:
redis:
environment:
- REDIS_PASSWORD=$REDIS_PASSWORD
```
在执行docker-compose命令时,必须在docker-compose.yml所在的目录下执行。可以使用docker-compose -f docker-compose.yml up -d命令来创建并启动容器。使用docker ps -a命令可以查看构建出的镜像。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [【Docker系列】Docker Compose 环境变量](https://blog.csdn.net/weixin_48447848/article/details/122632551)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Docker-Compose 与 YAML 配置文件格式](https://blog.csdn.net/duanbaoke/article/details/119238309)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文