docker-compose.yml文件中的&符号的含义 [英] Meaning of ampersand (&) in docker-compose.yml file

查看:238
本文介绍了docker-compose.yml文件中的&符号的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了这个问题,想知道& django 是什么意思

I recently came across this and was wondering what &django means

version: '2'

services:
  django: &django

文档中,我看不到任何内容与此有关.

I can't see anything in the docs related to this.

推荐答案

这些是称为锚的YAML功能,并非Docker Compose特有.我建议您在URL下方查看更多详细信息

These are a YAML feature called anchors, and are not particular to Docker Compose. I would suggest you have a look at below URL for more details

https://learnxinyminutes.com/docs/yaml/

按照部分 EXTRA YAML功能

YAML还具有一个方便的功能,称为锚",可让您轻松复制文档中的内容.这两个键将具有相同的值:

YAML also has a handy feature called 'anchors', which let you easily duplicate content across your document. Both of these keys will have the same value:

anchored_content:& anchor_name 该字符串将显示为两个键的值.other_anchor: * anchor_name

anchored_content: &anchor_name This string will appear as the value of two keys. other_anchor: *anchor_name

锚点可用于复制/继承属性

base: &base
    name: Everyone has same name

foo: &foo
    <<: *base
    age: 10

bar: &bar
    <<: *base
    age: 20

这篇关于docker-compose.yml文件中的&符号的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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