为什么在设置docker项目时make init没有找到docker-compose?

为什么在设置docker项目时make init没有找到docker-compose?

我尝试在本地 kubuntu 22.04 上使用 docker 容器设置 laravel 应用程序并出现错误:

$ make init
Building containers
docker-compose build --no-cache
make: docker-compose: No such file or directory
make: *** [Makefile:13: build] Error 127

我想不久前 docker-compose 改变了它的格式,所以我收到这个错误:

master@master-at-home:/Project$ sudo apt  install docker-compose
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3-setuptools : Depends: python3-pkg-resources (= 59.6.0-1.2) but 59.6.0-1.2ubuntu0.22.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.

现在在我的系统中我有:

master@master-at-home:/Project$ uname -a
Linux master-at-home 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct  6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
master@master-at-home:/Project$ lsb_release -d; uname -r; uname -i
Description:    Ubuntu 22.04.3 LTS
6.2.0-35-generic
x86_64

在项目的 docker-compose.yml 中我发现:

services:
    laravel.test:
        build:
            context: ./docker/8.2
            dockerfile: Dockerfile

此 docker-compose 文件中没有指向 docker 的真实版本,就像我通常在 docker 项目中所做的那样

version: '3.X'

为什么我使用 python3-setuptools 包时遇到错误,我该如何安装 docker-compose ?

它能解决我的问题吗?

答案1

您可能应该docker-compose-v2从 Universe 存储库或docker-compose-pluginDocker 存储库安装(取决于您如何安装 Docker)。

sudo apt install docker-compose-v2

或者

sudo apt install docker-compose-plugin

然后,您可以创建一个别名,以便旧docker-compose命令运行新的命令结构(docker compose)。

alias docker-compose='docker compose'

希望这可以为您解决问题。

相关内容