无法在Linux上安装Docker compose。

5

我无法在我的Linux系统上安装Docker Compose。运行安装命令后出现以下错误:

~$ sudo apt-get -f install docker-compose
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 code : Depends: libnotify4 but it is not going to be installed
        Depends: libnss3 but it is not going to be installed
        Depends: libxkbfile1 but it is not going to be installed
        Depends: libgconf-2-4 but it is not going to be installed
        Depends: libsecret-1-0 but it is not going to be installed
 docker-compose : Depends: python-cached-property but it is not going to be installed
                  Depends: python-docker (>= 1.9.0) but it is not going to be installed
                  Depends: python-dockerpty (>= 0.4.1) but it is not going to be installed
                  Depends: python-docopt but it is not going to be installed
                  Depends: python-enum34 but it is not going to be installed
                  Depends: python-jsonschema but it is not going to be installed
                  Depends: python-requests (>= 2.6.1) but it is not going to be installed
                  Depends: python-six (>= 1.3.0) but it is not going to be installed
                  Depends: python-texttable but it is not going to be installed
                  Depends: python-websocket but it is not going to be installed
                  Depends: python-yaml but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

请问有人能帮我吗?我也试过sudo apt-get clean,但没有用。


1
你尝试过像错误信息所说的那样使用“apt-get -f install”命令吗? - jwodder
它说E:无法打开锁文件/var/lib/dpkg/lock - 打开(13: 权限被拒绝) E:无法锁定管理目录(/var/lib/dpkg/),您是root吗? - Blockchaindeveloper
1
所以,尝试使用sudo apt-get -f install而不带任何软件包 :) - Alejandro Galera
5个回答

6

我认为安装docker-compose最简单的方法是通过pip:

sudo apt-get install python-pip
sudo pip install docker-compose

3

在Linux系统上安装Docker Compose
1. 运行以下命令以下载最新版本的Docker Compose:

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2. 给二进制文件应用可执行权限:

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

3. 测试安装。

$ docker-compose --version

请参考Docker手册以获取更详细的信息:https://docs.docker.com/compose/install/

2
我尝试了这个命令,但是得到了“docker-compose --version usr/bin/docker-compose no such file or directory”的错误提示。 - skrhee

1
sudo curl -L "https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

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

docker-compose --version

请注意 v2.17.2 中的 "v"。对于 1.x 版本,请删除 "v"。

0
你好,你无法获取依赖包。可能是因为你的系统过旧,而仓库中的软件包不再受支持,例如在 Wheezy 中。也可能是其他问题。我不知道,因为你没有提供更多关于你使用的系统的信息(例如系统版本、仓库列表 - cat /etc/apt/sources.list 等)。我建议你使用官方教程,在 Debian 上安装 docker-compose,官方教程链接:src: https://docs.docker.com/compose/install/(你可以使用 curl 下载最新的二进制 docker-compose 并适配使用,或者使用 pip 工具按照官方教程安装 docker-compose),或者使用本页面提供的解决方案(例如 pip 工具)。我使用了 Docker 官方教程重新安装了 docker-compose(到最新版本)。这很有帮助。我使用的是 Debian 9 “Stretch”(最新稳定版)。
附注:当你使用其他方法安装 docker-compose 时,请不要忘记删除旧版本的 docker-compose 安装。

0
你不需要安装Docker Compose。它作为一个Docker镜像可以从Docker Hub获取,因此您可以从Docker中运行它。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接