启动Docker容器报错,docker-compose版本太低


报错信息

root@bafang:/data/safeline# docker-compose up -d
Recreating 69633ed9eb3b_safeline-chaos ... 
Recreating 89aa50a4b934_safeline-tengine ... 
Recreating 80758fadde10_safeline-fvm     ... 
Recreating 3cde43fa9cef_safeline-detector ... 
Recreating b27f499b6854_safeline-pg       ... 

ERROR: for 69633ed9eb3b_safeline-chaos  'ContainerConfig'

ERROR: for 89aa50a4b934_safeline-tengine  'ContainerConfig'

ERROR: for b27f499b6854_safeline-pg  'ContainerConfig'

ERROR: for 3cde43fa9cef_safeline-detector  'ContainerConfig'

ERROR: for 80758fadde10_safeline-fvm  'ContainerConfig'

ERROR: for chaos  'ContainerConfig'

ERROR: for tengine  'ContainerConfig'

ERROR: for postgres  'ContainerConfig'

ERROR: for detect  'ContainerConfig'

ERROR: for fvm  'ContainerConfig'
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 203, in perform_command
  File "compose/metrics/decorator.py", line 18, in wrapper
  File "compose/cli/main.py", line 1186, in up
  File "compose/cli/main.py", line 1182, in up
  File "compose/project.py", line 702, in up
  File "compose/parallel.py", line 108, in parallel_execute
  File "compose/parallel.py", line 206, in producer
  File "compose/project.py", line 688, in do
  File "compose/service.py", line 581, in execute_convergence_plan
  File "compose/service.py", line 503, in _execute_convergence_recreate
  File "compose/parallel.py", line 108, in parallel_execute
  File "compose/parallel.py", line 206, in producer
  File "compose/service.py", line 496, in recreate
  File "compose/service.py", line 615, in recreate_container
  File "compose/service.py", line 334, in create_container
  File "compose/service.py", line 922, in _get_container_create_options
  File "compose/service.py", line 962, in _build_container_volume_options
  File "compose/service.py", line 1549, in merge_volume_bindings
  File "compose/service.py", line 1579, in get_container_data_volumes
KeyError: 'ContainerConfig'
[100108] Failed to execute script docker-compose

问题原因

旧版本的 Docker Compose 可能与当前的 Docker 版本不兼容。建议升级到最新版本的 Docker Compose

解决办法

使用迅雷下载这个文件:
https://github.com/docker/compose/releases/latest/download/docker-compose-Linux-x86_64

然后传到Linux机器。

把下载的文件移动到/usr/local/bin/:
mv docker-compose /usr/local/bin/docker-compose

增加可执行权限:
chmod +x /usr/local/bin/docker-compose

验证版本(2025年4月最新版本v2.34.0):
docker-compose -v


八方网域 2025年3月31日 14:56 收藏文档