docker-compose.yml端口上的引号有什么区别? [英] Quotes on docker-compose.yml ports make any difference?

查看:264
本文介绍了docker-compose.yml端口上的引号有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道 docker-compose.yml 文件中带引号或不带引号的端口之间是否有区别,找不到任何好的文档.

I don't know if there is a difference between ports with or without quotes in a docker-compose.yml file, can't find any good documentation.

  • 带引号
ports:
  - "80:80"
  - "443:443"

  • 不带引号
  • ports:
      - 80:80
      - 443:443
    

    我看到它运行时没什么不同

    I see no difference when I run it

    推荐答案

    Docker Compose文件版本3参考中的注释:

    Note from Docker Compose file version 3 reference:

    以HOST:CONTAINER格式映射端口时,使用小于60的容器端口可能会遇到错误的结果,因为YAML会将xx:yy格式的数字解析为以60为基数的值.因此,我们建议始终将端口映射明确指定为字符串.

    When mapping ports in the HOST:CONTAINER format, you may experience erroneous results when using a container port lower than 60, because YAML parses numbers in the format xx:yy as a base-60 value. For this reason, we recommend always explicitly specifying your port mappings as strings.

    https://docs.docker.com/compose/compose-file/compose-file-v3/#ports

    这篇关于docker-compose.yml端口上的引号有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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