
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Dockerfile linksApache Cassandra is an open source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers robust support for clusters spanning multiple datacenters, with asynchronous masterless replication allowing low latency operations for all clients.
***.org/wiki/Apache_Cassandra
!https://raw.githubusercontent.com/bandsintown/docker-cassandra/master/logo.png
This image is derived from the Official Cassandra image bundling https://www.consul.io/ and https://github.com/hashicorp/consul-template.
https://www.consul.io/ is a service discovery tool and is used in this image to dynamically discover the other cassandra nodes in order to define those nodes as Cassandra seeds. The configuration is created at the container startup and is managed by https://github.com/hashicorp/consul-template
https://github.com/hashicorp/consul-template allows to change dynamically the Cassandra configuration as well, without rebundling and redeploying an image.
cassandra server instanceStarting a Cassandra instance is simple:
console$ docker run --name some-cassandra -d bandsintown/cassandra:2.1.18
... where some-cassandra is the name you want to assign to your container and tag is the tag specifying the Cassandra version you want. See the list above for relevant tags.
This image exposes the standard Cassandra ports (see the https://wiki.apache.org/cassandra/FAQ#ports), so container linking makes the Cassandra instance available to other application containers. Start your application container like this in order to link it to the Cassandra container:
console$ docker run --name some-app --link some-cassandra:cassandra -d app-that-uses-cassandra
Using the environment variables documented below, there are two cluster scenarios: instances on the same machine and instances on separate machines. For the same machine, start the instance as described above. To start other instances, just tell each new node where the first is.
console$ docker run --name some-cassandra2 -d -e CASSANDRA_SEEDS="$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' some-cassandra)" bandsintown/cassandra:2.1.18
... where some-cassandra is the name of your original Cassandra Server container, taking advantage of docker inspect to get the IP address of the other container.
Or you may use the docker run --link option to tell the new node where the first is:
console$ docker run --name some-cassandra2 -d --link some-cassandra:cassandra bandsintown/cassandra:2.1.18
For separate machines (ie, two VMs on a cloud provider), you need to tell Cassandra what IP address to advertise to the other nodes (since the address of the container is behind the docker bridge).
Assuming the first machine's IP address is 10.42.42.42 and the second's is 10.43.43.43, start the first with exposed gossip port:
console$ docker run --name some-cassandra -d -e CASSANDRA_BROADCAST_ADDRESS=10.42.42.42 -p 7000:7000 bandsintown/cassandra:2.1.18
Then start a Cassandra container on the second machine, with the exposed gossip port and seed pointing to the first machine:
console$ docker run --name some-cassandra -d -e CASSANDRA_BROADCAST_ADDRESS=10.43.43.43 -p 7000:7000 -e CASSANDRA_SEEDS=10.42.42.42 bandsintown/cassandra:2.1.18
This image bundle https://github.com/hashicorp/consul-template to create the Cassandra configuration at startup. The configuration can also be changed just setting keys in Consul.
This project has a docker-compose.yml file defining a Cassandra service running along Consul.
To use it just create the services:
console$ docker-compose up -d
Then scale the cassandra cluster to the number of nodes desired:
console$ docker-compose scale cassandra=3
When all nodes are up and running you can chck the cluster is created properly:
console$ docker-compose exec cassandra nodetool status root@/etc/cassandra > nodetool status Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 172.21.0.6 61.24 KB 256 69.3% 1d0ea42f-199d-4b26-bb17-1a878ac16740 rack1 UN 172.21.0.5 171.4 KB 256 68.1% 4785f6bc-3c59-4f4b-8da7-14a61e2370d9 rack1 UN 172.21.0.4 82.52 KB 256 62.6% 40a505e9-bf80-498f-bc9a-39aeec5539bb rack1
cqlshThe following command starts another Cassandra container instance and runs cqlsh (Cassandra Query Language Shell) against your original Cassandra container, allowing you to execute CQL statements against your database instance:
console$ docker run -it --link some-cassandra:cassandra --rm cassandra sh -c 'exec cqlsh "$CASSANDRA_PORT_9042_TCP_ADDR"'
... or (simplified to take advantage of the /etc/hosts entry Docker adds for linked containers):
console$ docker run -it --link some-cassandra:cassandra --rm cassandra cqlsh cassandra
... where some-cassandra is the name of your original Cassandra Server container.
More information about the CQL can be found in the https://cassandra.apache.org/doc/cql3/CQL.html.
The docker exec command allows you to run commands inside a Docker container. The following command line will give you a bash shell inside your cassandra container:
console$ docker exec -it some-cassandra bash
The Cassandra Server log is available through Docker's container log:
console$ docker logs some-cassandra
When you start the cassandra image, you can adjust the configuration of the Cassandra instance by passing one or more environment variables on the docker run command line.
CASSANDRA_LISTEN_ADDRESSThis variable is for controlling which IP address to listen for incoming connections on. The default value is auto, which will set the listen_address option in cassandra.yaml to the IP address of the container as it starts. This default should work in most use cases.
CASSANDRA_BROADCAST_ADDRESSThis variable is for controlling which IP address to advertise to other nodes. The default value is the value of CASSANDRA_LISTEN_ADDRESS. It will set the broadcast_address and broadcast_rpc_address options in cassandra.yaml.
CASSANDRA_RPC_ADDRESSThis variable is for controlling which address to ***d the thrift rpc server to. If you do not specify an address, the wildcard address (0.0.0.0) will be used. It will set the rpc_address option in cassandra.yaml.
CASSANDRA_START_RPCThis variable is for controlling if the thrift rpc server is started. It will set the start_rpc option in cassandra.yaml.
CASSANDRA_SEEDSThis variable is the comma-separated list of IP addresses used by gossip for bootstrapping new nodes joining a cluster. It will set the seeds value of the seed_provider option in cassandra.yaml. The CASSANDRA_BROADCAST_ADDRESS will be added the the seeds passed in so that the sever will talk to itself as well.
CASSANDRA_CLUSTER_NAMEThis variable sets the name of the cluster and must be the same for all nodes in the cluster. It will set the cluster_name option of cassandra.yaml.
CASSANDRA_NUM_TOKENSThis variable sets number of tokens for this node. It will set the num_tokens option of cassandra.yaml.
CASSANDRA_DCThis variable sets the datacenter name of this node. It will set the dc option of cassandra-rackdc.properties.
CASSANDRA_RACKThis variable sets the rack name of this node. It will set the rack option of cassandra-rackdc.properties.
CASSANDRA_ENDPOINT_SNITCHThis variable sets the snitch implementation this node will use. It will set the endpoint_snitch option of cassandra.yml.
Important note: There are several ways to store data used by applications that run in Docker containers. We encourage users of the cassandra images to familiarize themselves with the options available, including:
The Docker documentation is a good starting point for understanding the different storage options and variations, and there are multiple blogs and forum postings that discuss and give advice in this area. We will simply show the basic procedure here for the latter option above:
Create a data directory on a suitable volume on your host system, e.g. /my/own/datadir.
Start your cassandra container like this:
console$ docker run --name some-cassandra -v /my/own/datadir:/var/lib/cassandra -d bandsintown/cassandra:2.1.18
The -v /my/own/datadir:/var/lib/cassandra part of the command mounts the /my/own/datadir directory from the underlying host system as /var/lib/cassandra inside the container, where Cassandra by default will write its data files.
Note that users on host systems with SELinux enabled may see issues with this. The current workaround is to assign the relevant SELinux policy type to the new data directory so that the container will be allowed to access it:
console$ chcon -Rt svirt_sandbox_file_t /my/own/datadir
If there is no database initialized when the container starts, then a default database will be created. While this is the expected behavior, this means that it will not accept incoming connections until such initialization completes. This may cause issues when using automation tools, such as docker-compose, which start several containers simultaneously.
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 bandsintown/cassandra 相关的常用 Docker 镜像,适用于 不同场景 等不同场景: