我正在尝试使用docker compose启动cassandra容器,但仍收到以下错误消息:
cassandra-server_1 | Connection error: ('Unable to connect to any servers',
{'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
请注意,当我直接使用以下命令行时,它运行良好:
$ docker run -d --name=c1 bitnami/cassandra:3.11.6
然后我ssh容器,并使用 CQLSH
命令正常。
我知道这与网络有关,我尝试了我所能做的一切,但都没有成功!
这是我的docker compose文件:
version: '3.4'
services:
cassandra-server:
image: 'bitnami/cassandra:3.11.6'
network_mode: host
expose:
- 7000
- 7001
- 7199
- 9042
- 9142
ports:
- '9042:9042'
command: bash -c 'cqlsh'
我用的是 network mode: Host
从切换后 bridge mode
.
这是我的另一个配置 bridge mode
:
version: '3.4'
networks:
app-tier:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
services:
cassandra-server:
image: 'bitnami/cassandra:3.11.6'
networks:
- aapp-tier
expose:
- 7000
- 7001
- 7199
- 9042
- 9142
ports:
- '9042:9042'
command: bash -c 'cqlsh'
不幸的是,对于这两种配置,我得到了相同的错误消息。
更新:
启动此命令时:
docker run -it --rm --network app-tier bitnami/cassandra:latest cqlsh --username cassandra --password cassandra
我收到此错误消息:
Traceback (most recent call last):
File "/opt/bitnami/cassandra/bin/cqlsh.py", line 2443, in <module>
main(*read_options(sys.argv[1:], os.environ))
File "/opt/bitnami/cassandra/bin/cqlsh.py", line 2421, in main
encoding=options.encoding)
File "/opt/bitnami/cassandra/bin/cqlsh.py", line 485, in __init__
load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname]),
File "/opt/bitnami/cassandra/bin/../lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/policies.py", line
417, in __init__
socket.gaierror: [Errno -2] Name or service not known
信息版本
版本
的输出 docker version
:
Client:
Version: 19.03.1
API version: 1.40
Go version: go1.12.7
Git commit: 74b1e89e8a
Built: Wed Jul 31 15:18:18 2019
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea838
Built: Wed Nov 13 07:28:45 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683
的输出 docker info
:
Client:
Debug Mode: false
Server:
Containers: 2
Running: 1
Paused: 0
Stopped: 1
Images: 7
Server Version: 19.03.5
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.14.154-boot2docker
Operating System: Boot2Docker 19.03.5 (TCL 10.1)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 989.5MiB
Name: default
ID: VOY2:F3HL:T3RR:5RYH:RTGG:6HOS:EPZ3:WIYL:J22K:UVAD:ZHEQ:TDRW
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode: false
Username: progwebinfo
Registry: https://index.docker.io/v1/
Labels:
provider=virtualbox
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
的输出 docker-compose version
(如适用):
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018
其他环境详细信息(aws、virtualbox、docker for mac、physical等):
我在Windows7 24位上使用docker工具箱
暂无答案!
目前还没有任何答案,快来回答吧!