1

Can someone tell me how to change cassandra.yaml inside a docker container? I want to enable password authentication inside docker for cassandra access.

adroit
  • 31
  • 5
  • 2
    You could try to mount an external file, like explained at https://stackoverflow.com/questions/42248198/how-to-mount-a-single-file-in-a-volume – Nico Haase May 07 '18 at 08:12

2 Answers2

2

If you're using the official Cassandra Docker image, you'll already have the docker-entrypoint.sh. See: https://github.com/docker-library/cassandra/blob/master/docker-entrypoint.sh for some of the variables already defined, as examples.

To have these included when your container starts, you could:

  1. fork and edit the docker-entrypoint.sh starting at (currently) line 51 to add your own variables like this:

for yaml in \ broadcast_address \ broadcast_rpc_address \ [your_selected_yaml_variable] \ ...

  1. include the values you want to override in docker-compose.yml like this:

environment: - CASSANDRA_SEEDS=DC1C1,DC1C2,DC2C1,DC2C2 - CASSANDRA_CLUSTER_NAME=Dev_Cluster - CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch - CASSANDRA_[YOUR_SELECTED_YAML_VARIABLE]

Valerie Parham-Thompson
  • 1,516
  • 1
  • 11
  • 21
0

You could create a docker entry point (basically it'a script file that you instruct Docker to copy on the container and it's defined as entrypoint).

COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["bin/sh", "/docker-entrypoint.sh"]

In that file you can do whatever changes you like on cassandra.yaml file using sed.

sed -ri '/^# data_file_directories:/{n;s/^#.*/'"    - $CASSANDRA_DATA_DIRECTORY"'/}' "$CASSANDRA_CONFIG/cassandra.yaml"

Note that $CASSANDRA_DATA_DIRECTORY and $CASSANDRA_CONFIG are some variables defined in advance.

Horia
  • 2,942
  • 7
  • 14