how to configure Cassandra.yaml which is inside docker image of cassandra at /etc/cassandra/cassandra.yaml
Asked Answered
B

3

7

I am trying to edit cassandra.yaml which is inside docker container at /etc/cassandra/cassandra.yaml, I can edit it from logging inside the container, but how can i do it from host?

Baseball answered 29/6, 2018 at 23:1 Comment(0)
C
5

Multiple ways to achieve this from host to container. You can simple use COPY or RUN in Dockerfile or with basic linux commands as sed, cat, etc. to place your configuration into the container. Another way you can pass environment variables while running your cassandra image which will pass those environment variables to the spawning container. Also, can use the docker volume mount it from host to container and you can map the configuration you want into the cassandra.yaml as shown below,

$ docker container run -v ~/home/MyWorkspace/cassandra.yaml:/etc/cassandra/cassandra.yaml your_cassandra_image_name

If you are using Docker Swarm then you can use Docker configs to externally store the configuration files(Even other external services can be used as etcd or consul). Hope this helps.

Chlorenchyma answered 30/6, 2018 at 11:10 Comment(2)
Ok, I am also worried about how to change the sysctl file. Maximum number of memory map areas per process (vm.max_map_count) 262144 is too low, recommended value: 1048575, you can change it with sysctl.Baseball
check it out using the $ grep vm.max_map_count /etc/sysctl.conf then set the value as $ sudo echo 1048575 > /proc/sys/vm/max_map_count execute on the host machine. Even you can sue sysctl as you mentioned.Chlorenchyma
R
1

To edit cassandra.yaml :

1) Copy your file from your Docker container to your system

From command line :

docker ps

(To get your container id)

Then :

docker cp your_container_id:\etc\cassandra\cassandra.yaml C:\Users\your_destination

Once the file copied you should be able to see it in your_destination folder

2) Open it and make the changes you want

3) Copy your file back into your Docker container

docker cp C:\Users\your_destination\cassandra.yaml your_container_id:\etc\cassandra

4) Restart your container for the changes to be effective

Reverberate answered 23/6, 2022 at 10:33 Comment(0)
P
0

Install vim on your docker container and edit the file on the container directly (Assumption: You are comfortable using vim).

  1. Enter bash mode on your container
$ docker exec -it <container_id/container_name> bash
  1. Update package manager and install vim
:/# apt update
:/# apt install vim
  1. Edit your file with vim.
:/# vim /etc/cassandra/cassandra.yaml
  1. Get out of container's interactive mode (back to your OS's terminal.
:/# exit
  1. Restart your container for changes to cassandra.yaml to take effect
$ docker restart <container_id/container_name>
Prady answered 25/11, 2023 at 12:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.