I am trying to launch cassandra container using docker-compose, but stay recieving this error message:
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")})
Notice that I get it working well when I use directly this command line:
$ docker run -d --name=c1 bitnami/cassandra:3.11.6
And then I ssh the container, and using CQLSH command normaly.
I know it is related to the networking, and I tried everything I was able to without success !
Here is my docker-compose file:
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'
I am using the network mode: Host after switching from bridge mode.
Here is my other configuration with 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'
Unfortunately I get the same error message for both configurations.
UPDATE:
When I launch this command:
docker run -it --rm --network app-tier bitnami/cassandra:latest cqlsh --username cassandra --password cassandra
I recieve this error message:
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
Info versions
Version
- Output of
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
- Output of
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
- Output of
docker-compose version(if applicable):
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
Additional environment details (AWS, VirtualBox, Docker for MAC, physical, etc.):
I am on Windows 7 24bit Using Docker Toolbox