To the point I’m at I have run the following commands in my vs code terminal
docker network create cassandra-net
docker run --name my-cassandra --network cassandra-net -p 9042:9042 -d cassandra:latest
The book now wants me to run the following command
docker run -it --network cassandra-net --rm cassandra cqlsh my-cassandra
and I’m getting this error
Traceback (most recent call last):
File "/opt/cassandra/bin/cqlsh.py", line 2402, in <module>
main(*read_options(sys.argv[1:], os.environ))
File "/opt/cassandra/bin/cqlsh.py", line 2344, in main
shell = Shell(hostname,
File "/opt/cassandra/bin/cqlsh.py", line 480, in __init__
load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname]),
File "/opt/cassandra/bin/../lib/cassandra-driver-internal-only-3.25.0.zip/cassandra-driver-3.25.0/cassandra/policies.py", line 425, in __init__
File "/opt/cassandra/bin/../lib/cassandra-driver-internal-only-3.25.0.zip/cassandra-driver-3.25.0/cassandra/policies.py", line 426, in <listcomp>
File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
In the docker logs it has reached the point where the output is
"2024-04-10 06:46:40 INFO [OptionalTasks:1] 2024-04-10 12:46:40,062 CassandraRoleManager.java:354 – Created default superuser role ‘cassandra’"
and there is no further output in the logs so I’m assuming "Cassandra cluster is fully started" as the book warns about.
I tried searching this error, and I’m able to find individual slices of the issue, but nothing completely matches the issue.
I search
File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
and get some python specific troubleshooting.
I search the full error and was directed to a github thread
https://github.com/orgs/community/discussions/26047
but this thread has fixes that assume you’re hosting the container on github, and the fixes include updating a yml file on github.
I am only trying to run the container and execute these commands from the vscode terminal, not hosting anything on github yet.
What am I missing?
2
Answers
I copied this command from the book docker run -it --network cassandra-net --rm cassandra cqlsh my-cassandra
I was actually running docker run -it --network cassandra-net --rm cassandra cqlsh mycassandra
This error:
means that Docker is unable to resolve the host that you specified.
The most likely cause for this is that you had a typo in the name when (a) you created the container, or (b) connecting with cqlsh.
Check that you are using the same container name consistently in all your Docker commands and try again. Cheers!