Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does Cassandra docker image require root privileges to run?

I am using the latest Cassandra docker image. When I run it with root privileges, cqlsh is able to connect to Cassandra service as expected:

$ sudo docker run --name mycassandra -d cassandra:latest
$ sudo docker exec -it mycassandra bash
# cqlsh
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.0.0 | Cassandra 4.0.3 | CQL spec 3.4.5 | Native protocol v5]
Use HELP for help.
cqlsh> 

However, if I run docker image with normal user privileges, I get an error when using cqlsh:

$ docker run --name mycassandra1 -d cassandra:latest
$ docker exec -it mycassandra1 bash
# cqlsh
Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': 
ConnectionRefusedError(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: 
Connection refused")})

I prefer not to run docker image as sudo. Wondering why Cassandra image requires sudo privileges. Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It looks like you’re a member of the docker group since you can run docker without sudo. Whether you run it with or without sudo shouldn’t make a difference. The container runs as root in both cases, which you can verify by the # bash prompt in both cases.

What I think is happening is that you’re trying to run cqlsh before the container has finished starting up. Check the container log and make sure you see Startup complete before you try running cqlsh.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading