我正在为使用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版本,但我不能这样做,因为它不支持我的撰写文件。所以我接下来要做的就是改变API版本。
export COMPOSE_API_VERSION=auto
然后在运行docker-compose之后我得到了这个错误。
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
Docker Info:
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
答案 0 :(得分:-1)
docker-engine
软件包很旧,可能来自您的分发供应商而不是docker。我建议您按照以下步骤直接从docker安装docker-ce
。