ttt
ttt

Reputation: 4004

Cassandra official guide docker start command network not working

I am new to Docker and Cassandra and tried their quick start guide to setup Cassandra with Docker locally however meeting following issues.

I can successfully run the command to start Cassandra which is:

docker run --name cassandra cassandra

However when I tried with the command of network:

docker run --rm -d --name cassandra --hostname cassandra --network cassandra cassandra

it got failed with following errors:

docker: Error response from daemon: Conflict. The container name "/cassandra" is already in use by container "c356c1b25bd096e4c6e0f2afd40a70f375ee34fff332b1b0ba16e14d1f6ab0fc". You have to remove (or rename) that container to be able to reuse that name.

Not quite sure what is the reason here? BTW, I am using the latest version of Docker for Mac as 4.1.1

Upvotes: 3

Views: 1020

Answers (3)

Valerio Arnaudo
Valerio Arnaudo

Reputation: 41

The step two in the official guide is ambiguous. You don't need and you wont be able to run both commands. Try to run just:

docker run --rm -d --name cassandra --hostname cassandra --network cassandra cassandra

If you receive the error about the network that does not exist run:

docker network create cassandra

Create the CQL script as the guide tells you and make sure you are in the same path as where you will create the file. Then try to run step 5 (the interactive CQLSH) before running the script. If you receive an error it is probably due to the version that you are using (I had to upgrade to 3.4.5). When you are sure about the version then you can try to run the script with the command in step 4 like this:

docker run --rm --network cassandra -v "$(pwd)/data.cql:/scripts/data.cql" -e CQLSH_HOST=cassandra -e CQLSH_PORT=9042 -e CQLVERSION="3.4.5" nuvo/docker-cqlsh

Replace the CQLVERSION with the correct version and your script should run smoothly. Then finally run again the interactive command line and check that the data is there!

Hope it was helpful!

Upvotes: 4

Erick Ramirez
Erick Ramirez

Reputation: 16323

The error means that you already have a container running called cassandra. You can't use the same name to start another container.

Run docker ps -a to list all containers on your Mac. If you don't need the container called cassandra anymore, you can terminate it with docker rm.

If you're interested, I find this Docker cheat sheet very handy since I'm not an expert either. Cheers!

Upvotes: 1

gohm'c
gohm'c

Reputation: 15490

If you have not docker rm <existing container named cassandra>, second run with same name will be rejected. Do a docker ps -a to see if such container exist.

Upvotes: 1

Related Questions