docker-compose.yml 端口上的引用有什么不同吗? [英] Quotes on docker-compose.yml ports make any difference?

查看:19
本文介绍了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

    推荐答案

    Note from Docker Compose file version 3 reference:

    Note from Docker Compose file version 3 reference:

    以 HOST:CONTAINER 格式映射端口时,使用低于 60 的容器端口时可能会遇到错误结果,因为 YAML 将格式为 xx:yy 的数字解析为 base-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天全站免登陆