我已经在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
我正在安装树莓派3,在树莓操作系统上。curl方法没有解析为有效响应。它还说{错误:未找到},我看了一下URL https://github.com/docker/compose/releases/download/1.11.2/docker-compose-Linux-armv7l,它是无效的。我猜那里没有建筑。
这个指南https://github.com/hypriot/arm-compose对我很有用。
sudo apt-get update
sudo apt-get install -y apt-transport-https
echo "deb https://packagecloud.io/Hypriot/Schatzkiste/debian/ jessie main" | sudo tee /etc/apt/sources.list.d/hypriot.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 37BBEE3F7AD95B3F
sudo apt-get update
sudo apt-get install docker-compose
我正在安装树莓派3和树莓8。curl方法对我来说失败了(得到了第一行:Not:命令没有在请求docker-compose——version时发现错误),@sunapi386的解决方案似乎有点过时,所以我尝试了这个工作:
首先清理之前的工作:
sudo rm /usr/local/bin/docker-compose
sudo pip uninstall docker-compose
然后在Rpi上遵循以下指导:
sudo apt-get -y install python-pip
sudo pip install docker-compose
对我来说(2017年11月1日),这导致了以下对docker-compose——version的响应:
docker-compose version 1.16.1, build 6d1ac219
参考上面给出的答案(我没有足够的声誉单独提到单独的解决方案,因此我在这里集体做这些),我想补充一些重要的建议:
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.
问候,
亚当
在Linux上,您可以从GitHub上的Compose存储库发布页面下载Docker Compose二进制文件。按照链接中的说明操作,其中包括在终端上运行curl命令来下载二进制文件。这些分步指导也包括在下面。
1:执行此命令下载Docker Compose当前稳定版本:
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
若要安装不同版本的Compose,请将1.26.2替换为您想使用的Compose版本。
2:应用可执行权限的二进制文件:
sudo chmod +x /usr/local/bin/docker-compose
注意:如果安装后命令docker-compose失败,请检查
你的路。您还可以创建到/usr/bin或任何的符号链接
路径中的其他目录。
如果docker-compose已经存在于/usr/local/bin中:
ls -alt /usr/local/bin/ | grep docker-compose
> lrwxr-xr-x 1 root wheel 77 Mar 11 10:39 docker-compose -> /Applications/Docker.app/Contents/Resources/bin/docker-compose/docker-compose
最后用/usr/local/bin更新你的.bash_profile路径:
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH:/usr/local/bin"
Run:
source ~/.bash_profile
并检查:
echo $PATH
> ...
which docker-compose
> /usr/local/bin/docker-compose
docker-compose
尝试在CentOS上使用curl per docker docs安装docker-compose(适用于Linux)。在这些步骤之后,它返回一个错误
docker-compose -v
/usr/local/bin/docker-compose: line 1: Not: command not found
有趣的是,docker-compose文件在第一行只包含“Not Found”(它应该是二进制文件)
cat /usr/local/bin/docker-compose
Not Found
这意味着我试图从github链接卷曲不存在。我失败的链接是:
sudo curl -L "https://github.com/docker/compose/releases/download/2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
在本地运行uname -s和uname -m可以看到需要添加到下载url中的内容
uname -s
Linux
uname -m
x86_64
在浏览器中尝试url
https://github.com/docker/compose/releases/download/2.2.2/docker-compose-linux-x86_64
显示未找到该页面。
一个他们在版本中添加“v”的问题,如v2.2.2。所以下载url应该是v
https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-linux-x86_64。他们的发布:https://github.com/docker/compose/releases/
这是有效的(注意v2.2.2)
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v
Docker Compose version v2.2.2
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 v1,可以按照如下方式安装:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
关于安装Docker Compose v2,可以参考这里。
关于新的compose和旧的docker-compose之间的命令兼容性,您可以参考这里。
如果你用的是ubuntu, docker compose可以工作,但docker-compose不行,你需要旧的docker-compose语法可用(可能第三方库使用它),你可以通过以下步骤修复它:
docker-compose插件可能安装在/usr/libexec/docker/cli-plugins/docker-compose(确保它是)
创建一个符号链接到它:
sudo ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose
现在docker-compose应该可用了
更新:
如果docker-compose在上述路径中找不到,您可以从您的操作系统的发布页面手动下载它,然后移动下载的文件并使其可执行。
cd ~/Downloads
sudo mv ./docker-compose-* /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
在Amazon Linux中,如果您将使用哪个docker-compose
您将得到以下错误
[root@ip bin]#哪个docker-compose
no docker-compose in (/sbin:/bin:/usr/sbin:/usr/bin)
只需mv docker-compose从/usr/local/bin到/usr/bin
[root@ip bin]# mv docker-compose /usr/bin
[root@ip bin]#哪个docker-compose
/ bin / sh docker-compose
[root@ip-172-31-36-121 bin]# docker-compose——version
Docker-compose版本1.29.2,构建未知