解决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 format Docker Engine release
3.8 19.03.0+
3.7 18.06.0+
3.6 18.02.0+
3.5 17.12.0+
3.4 17.09.0+
3.3 17.06.0+
3.2 17.04.0+
3.1 1.13.1+
3.0 1.13.0+
2.4 17.12.0+
2.3 17.06.0+
2.2 1.13.0+
2.1 1.12.0+
2.0 1.10.0+
1.0 1.9.1.+
Logo

云原生社区为您提供最前沿的新闻资讯和知识内容

更多推荐