解决You might be seeing this error because you're using the wrong Compose file version

报错问题

[root@localhost docker]# docker-compose up -d
ERROR: The Compose file ‘./docker-compose.yml’ is invalid because:
Invalid top-level property “mall_trade_server”. Valid top-level sections for this Compose file are: services, version, networks, volumes, and extensions starting with “x-”.

You might be seeing this error because you’re using the wrong Compose file version. Either specify a supported version (e.g “2.2” or “3.3”) and place your service definitions under the services key, or omit the version key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

原因

docker-compose.yml 里面的version对应的版本不对

解决

docker-compose.yml版本要求看下面对应表,写入正确的对应版本version即可

Compose file formatDocker Engine release
3.819.03.0+
3.718.06.0+
3.618.02.0+
3.517.12.0+
3.417.09.0+
3.317.06.0+
3.217.04.0+
3.11.13.1+
3.01.13.0+
2.417.12.0+
2.317.06.0+
2.21.13.0+
2.11.12.0+
2.01.10.0+
1.01.9.1.+
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐