docker-ERROR: Version in “./docker-compose.yaml” is unsupported.

1
2
3
root@ubuntu-server:~/dockerProject/myWebSite# docker-compose up
ERROR: Version in "./docker-compose.yaml" is unsupported. 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 多容器的时候出现了这个错误,原因似乎是 docker 版本和 docker-compose 版本过低导致

执行一下以下命令升级一下试试:

1
2
3
4
5
6
7
8
9
10
root@ubuntu-server:~# cd /usr/local/bin && sudo rm -rf docker-compose
root@ubuntu-server:/usr/local/bin# curl -SL https://github.com/docker/compose/releases/download/v2.1.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:01:26 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:01:29 --:--:-- 0^C
root@ubuntu-server:/usr/local/bin# chmod +x docker-compose
root@ubuntu-server:/usr/local/bin# docker-compose --version
Docker Compose version v2.1.1
root@ubuntu-server:/usr/local/bin#

更新: 2024-01-27 20:54:42
原文: https://www.yuque.com/zacharyblock/cx2om6/kh6sxrnthfdul5au