【问题标题】:How to fix dependencies for upgrading Docker engine?如何修复升级 Docker 引擎的依赖关系?
【发布时间】:2018-05-12 19:53:48
【问题描述】:

我正在为使用 redis 和 mysql 的 express.js 应用程序创建一个 docker-compose。我在 Linux Mint 的发行版上执行此操作。

当我跑步时

docker-compose up

我明白了

ERROR: client and server don't have same version (client : 1.22, server: 1.18)

所以我做的第一件事是尝试降级我的 compose 版本,但我不能这样做,因为它不支持我的 compose 文件。所以接下来我尝试的是更改 API 版本。

export COMPOSE_API_VERSION=auto

然后在运行 docker-compose up 后出现此错误。

Traceback (most recent call last):
  File "bin/docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 71, in main
  File "compose/cli/main.py", line 124, in perform_command
  File "compose/cli/command.py", line 41, in project_from_options
  File "compose/cli/command.py", line 121, in get_project
  File "compose/cli/command.py", line 92, in get_client
  File "compose/cli/docker_client.py", line 120, in docker_client
  File "site-packages/docker/api/client.py", line 166, in __init__
docker.errors.InvalidVersion: API versions below 1.21 are no longer supported by this library.
[25236] Failed to execute script docker-compose

所以此时我将 API 版本更改为它支持的版本,所以我运行了。

export COMPOSE_API_VERSION=1.22

然后我想升级 docker 引擎,所以我运行了这个命令。

sudo apt-get upgrade docker-engine

我收到了这个错误

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... 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:
 docker-engine : Depends: init-system-helpers (>= 1.18~) but 1.14ubuntu1 is to be installed
                 Depends: lsb-base (>= 4.1+Debian11ubuntu7) but 4.1+Debian11ubuntu6mint1 is to be installed
                 Depends: libdevmapper1.02.1 (>= 2:1.02.97) but 2:1.02.77-6ubuntu2 is to be installed
                 Depends: libltdl7 (>= 2.4.6) but 2.4.2-1.7ubuntu1 is to be installed
                 Depends: libsystemd0 but it is not installable
E: Unable to correct problems, you have held broken packages.

到目前为止,我找不到任何关于如何修复这些依赖项的信息,所以我想知道我在这里做错了什么以及如何让这个应用程序启动并与 Docker 一起运行?

我将在下面包含我的 docker-compose.yml 和 Dockerfile。

docker-compose.yml:

version: '2'
volumes:
services:
 web:
    build: .
    command: "PORT=3002 node bin/www"
    volumes:
      - .:/usr/app/
      - /usr/app/node_modules
    ports:
      - "3002:3002"
    depends_on:
      - redis
      - mysql
 redis:
    image: 'bitnami/redis:latest'
    environment:
        - ALLOW_EMPTY_PASSWORD=yes
    ports:
        - '6379:6379'
    volumes:
        - /path/to/redis-persistence:/bitnami
 mysql:
     image: mysql:5.7
     container_name: mysql
     restart: always
     environment:
         - MYSQL_ROOT_PASSWORD=goon
         - MYSQL_DATABASE=TERRA_TEST
         - MYSQL_DATABASE=TERRA_DEV
     ports:
         - "33061:3306"
volumes:
    appconf:

Dockerfile:

FROM ubuntu

Run apt-get update

Run apt-get install curl -y

Run curl -sL https://deb.nodesource.com/setup_10.x

Run apt-get install -y nodejs

Run apt-get install -y git

run apt-get install npm -y

Run git clone https://github.com/sdrafahl/TerraServer.git

ADD configKeys.json TerraServer/

WORKDIR /TerraServer

run npm install

EXPOSE 3002

CMD PORT=3002 node bin/www

码头工人信息:

Containers: 3
 Running: 1
 Paused: 0
 Stopped: 2
Images: 15
Server Version: 18.03.1-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 39
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-53-generic
Operating System: Linux Mint 18.1
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.756GiB
Name: shane-OptiPlex-980
ID: NAAR:UM5J:CQRX:QTJM:NFU4:IQWP:64XZ:SB4X:UEMR:X7S2:MEQ7:PG34
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

【问题讨论】:

  • 如果你玩过它,我建议完全删除 docker 并重新安装,就像在他们的文档中一样
  • 我刚才尝试这样做,但不幸的是它并没有改变任何东西。 @MazelTov
  • 我告诉你按照文档来做...docs.docker.com/install/linux/docker-ce/debian/#prerequisites ...再次尝试按照步骤操作,看到第一步是卸载名为 docker-engine 的旧 docker 版本和新的名为docker-ce
  • 你也应该发布docker info的输出
  • 当我切换到另一台机器时,它似乎工作得更好。我认为另一台机器除此之外还有一些问题,因为我遵循了这些步骤并且没有像我说的那样工作。但是现在我遇到了一个不同的问题。 @MazelTov->“错误:对于 web 无法启动服务 web:OCI 运行时创建失败:container_linux.go:348:启动容器进程导致“exec:\”PORT=3002\”:在 $PATH 中找不到可执行文件”:未知错误:启动项目时遇到错误。”

标签: node.js docker docker-compose dockerfile


【解决方案1】:

docker-engine 包很旧,可能来自您的分发供应商而不是 docker。我建议按照步骤直接从 docker 安装 docker-ce

https://docs.docker.com/install/linux/docker-ce/ubuntu/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-03
    • 2018-01-07
    • 2019-09-27
    • 1970-01-01
    • 2019-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多