Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 Debian 10.13 时运行 sudo docker compose up -d 报错 #22

Open
eausensa opened this issue Mar 10, 2024 · 3 comments
Open

使用 Debian 10.13 时运行 sudo docker compose up -d 报错 #22

eausensa opened this issue Mar 10, 2024 · 3 comments

Comments

@eausensa
Copy link

使用 Debian 10.13 搭建 Ultimate 版本时报错

配置完成后

使用 sudo docker-compose up -d 指令时报错

报错信息如下

services.service.browserless.environment.USE_CHROME_STABLE contains true, which is an invalid type, it should be a string, number, or a null
services.utility.watchtower.environment.WATCHTOWER_CLEANUP contains true, which is an invalid type, it should be a string, number, or a null

于是将 environment 中所有值为 truefalse 的配置修改为 "true""false" 才运行成功

请问一下这是由于 docker-compose 的版本问题造成的吗还是别的什么原因

@Colin-XKL
Copy link
Owner

这里我看了下,这个地方 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

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

@Colin-XKL
Copy link
Owner

目前不清楚是哪个版本开始对上面说的那个情况做了兼容,我本地使用的版本没有出现这个问题,贴一下我本地使用的 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"

@eausensa
Copy link
Author

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

➜ 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 字段中的布尔值不用引号包起来会报错的原因。
估计您应该使用了什么插件让其自动添加了引号。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants