我正在尝试在Cassandra启动后运行一个脚本来创建密钥空间。
这是我的码头组成:
version: '3.6'
services:
cassandra:
container_name: cassandra
image: bitnami/cassandra:3.11.2
volumes:
- ./cassandra_data:/bitnami
- ./scripts/cassandra_init.sh:/cassandra_init.sh
environment:
- CASSANDRA_USER=${CASSANDRA_USERNAME}
- CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD}
- CASSANDRA_CLUSTER_NAME=Testing
- CASSANDRA_PASSWORD_SEEDER=yes
entrypoint: ["/app-entrypoint.sh"]
command: ["nami","start","--foreground","cassandra","/cassandra_init.sh"]
volumes:
cassandra_data:
["nami","start","--foreground","cassandra"]
启动了卡桑德拉。如果我在没有添加脚本的情况下启动容器,它就可以正常工作。
但是,如果我启动包含我的脚本的容器,我会在容器启动后收到此错误:
nami ERROR Unknown command '/cassandra_init.sh'
我怎样才能做到这一点?
答案 0 :(得分:0)
我明白了。
在docker.compose中,我不得不调用脚本init.sh
并调用它:
version: '3.6'
services:
cassandra:
container_name: cassandra
image: bitnami/cassandra:3.11.2
volumes:
- ./cassandra_data:/bitnami
- ./scripts/cassandra_init.sh:/init.sh
environment:
- CASSANDRA_USER=${CASSANDRA_USERNAME}
- CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD}
- CASSANDRA_CLUSTER_NAME=Testing
- CASSANDRA_PASSWORD_SEEDER=yes
entrypoint: ["/app-entrypoint.sh"]
command: ["/init.sh"]
volumes:
cassandra_data:
并且脚本应该如下所示:
#!/bin/bash
nami start cassandra
echo "script stuff here to run after cassandra starts"