我已经在CentOS 7上安装了docker,运行如下命令:

curl -sSL https://get.docker.com/ | sh
systemctl enable docker && systemctl start docker
docker run hello-world

注意:helloworld运行正常,没有问题。

然而,当我试图运行docker-compose (docker-compose。yml存在并且有效)它只在CentOS上给了我错误(Windows版本的docker-compose文件工作良好)

/usr/local/bin/docker-compose: line 1: {error:Not Found}: command not found

当前回答

2022年5月更新

自2022年4月以来,docker compose V2是GA,现在它是docker桌面的一部分。你可以在这里看到所有相关信息。 Compose V1现在被标记为已弃用。

最初的回答:

Docker compose v1是一个单独的安装。要安装v1,请遵循此处的说明。

Docker compose v2目前是一个单独的安装,但当它准备好时,它将集成到Docker中。它被认为是一个docker插件。在这个时候,如果你想要docker撰写v2,因为这个提交你可以做:

sudo apt update \
&& sudo apt install docker-compose-plugin

用apt或相当于yum的词。这将以插件的形式安装新的docker compose V2。

其他回答

首先请检查docker-compose是否安装,

$ docker-compose -v

如果没有安装,请参考安装指南https://docs.docker.com/compose/install/ 如果安装,则给予二进制文件可执行权限。

$ chmod +x /usr/local/bin/docker-compose

检查一下是否有效。

安装docker并不意味着你已经安装了docker-compose。它有一个先决条件,那就是你已经安装了docker引擎。之后,你可以按照这个链接为Centos 7安装docker-compose。

参考上面给出的答案(我没有足够的声誉单独提到单独的解决方案,因此我在这里集体做这些),我想补充一些重要的建议:

docker-compose you can install from the repository (if you have this package in the repository, if not you can adding to system a repository with this package) or download binary with use curl - totourial on the official website of the project - src: https://docs.docker.com/compose/install / docker-compose from the repository is in version 1.8.0 (at least at me). This docker-compose version does not support configuration files in version 3. It only has version = <2 support. Inthe official site of the project is a recommendation to use container configuration in version 3 - src: https://docs.docker.com/compose/compose-file / compose-versioning /. From my own experience with work in the docker I recommend using container configurations in version 3 - there are more configuration options to use than in versions <3. If you want to use the configurations configurations in version 3 you have to do update / install docker-compose to the version of at least 1.17 - preferably the latest stable. The official site of the project is toturial how to do this process - src: https://docs.docker.com/compose/install/ when you try to manually remove the old docker-compose binaries, you can have information about the missing file in the default path /usr/local/bin/docker-compose. At my case, docker-compose was in the default path /usr/bin/docker-compose. In this case, I suggest you use the find tool in your system to find binary file docker-compose - example syntax: sudo find / -name 'docker-compose'. It helped me. Thanks to this, I removed the old docker-compose version and added the stable to the system - I use the curl tool to download binary file docker-compose, putting it in the right path and giving it the right permissions - all this process has been described in the posts above.

问候, 亚当

docker-compose目前是一个利用docker(-engine)的工具,但没有包含在docker的发行版中。

以下是安装手册的链接: https://docs.docker.com/compose/install/

TL; diana:

curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/bin/docker-compose

(1.8.0将在未来更改)

以上的解决方案对我不起作用。但我发现这个很管用:

sudo apt-get update -y && sudo apt-get install -y python3-pip python3-dev
sudo apt-get remove docker docker-engine docker.io
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo pip3 install docker-compose
#sudo docker-compose -f docker-compose-profess.yml pull ofw
sudo usermod -a -G docker $USER
sudo reboot