Giter Club home page Giter Club logo

Comments (3)

Colin-XKL avatar Colin-XKL commented on August 17, 2024

这里我看了下,这个地方 compose 文件里写 bool 值是其实不正确的,可能是我使用的 compose 插件版本做了额外的转换,能够正常使用,但是实际这个写法不是标准的。

YAML 文件支持 bool 类型的 value,但是对于环境变量来说, linux 环境变量都是字符串,如果在 compose 文件里用 map 的形式编写 env,value 又是 bool类型的话,解析器就会把那个值解析为 bool,但是linux 的环境变量需要的字符串,这个地方类型不匹配,你贴的报错日志就是这个情况。

docker 官方的文档是有提到环境变量所有的 bool 值都必须要用引号包起来,参见这里
https://docs.docker.com/compose/compose-file/compose-file-v3/#environment

看起来是个已知的问题。保险起见我后续会把项目中这种写法全部改掉

from rssmanx.

Colin-XKL avatar Colin-XKL commented on August 17, 2024

目前不清楚是哪个版本开始对上面说的那个情况做了兼容,我本地使用的版本没有出现这个问题,贴一下我本地使用的 os 和版本,供参考

➜ uname -a
Linux light-sg 6.1.0-11-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-4 (2023-08-08) x86_64 GNU/Linux

➜ docker compose version
Docker Compose version v2.21.0

➜ docker version
Client: Docker Engine - Community
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:08:02 2023
 OS/Arch:           linux/amd64
 Context:           default

➜ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"

from rssmanx.

eausensa avatar eausensa commented on August 17, 2024

非常抱歉,我忘记把自己的服务器环境贴上来了,下面是我自己的服务器环境

➜ uname -a
Linux BlogServer 5.10.0-0.deb10.27-rt-amd64 #1 SMP PREEMPT_RT Debian 5.10.205-2~deb10u1 (2024-01-04) x86_64 GNU/Linux

➜ docker compose version
Docker Compose version v2.24.7

➜ docker version
Client: Docker Engine - Community
 Version:           25.0.4
 API version:       1.44
 Go version:        go1.21.8
 Git commit:        1a576c5
 Built:             Wed Mar  6 16:32:13 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.4
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       061aa95
  Built:            Wed Mar  6 16:32:13 2024
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

➜ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"

我查询了一下 Docker Compose 相关的更新日志:

https://docs.docker.com/compose/release-notes/#170
1.7.0 Breaking Changes 中的第二条

Booleans are no longer allows as values for mappings in the Compose file (for keys environment, labels and extra_hosts). Previously this was a warning. Boolean values should be quoted so they become string values.

https://docs.docker.com/compose/release-notes/#bug-fixes-26
1.19.0 Bug fixes 中的最后一条

Added better validation of labels fields in Compose files. Label values containing scalar types (number, boolean) now get automatically converted to strings

所以这解释了在 labels 字段中的的布尔值不用引号包起来不会报错,而在 environment 字段中的布尔值不用引号包起来会报错的原因。
估计您应该使用了什么插件让其自动添加了引号。

from rssmanx.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.