Persisting data

To persist data, create directories on the local host and map the directory to the corresponding volume.

Persisting data allows the container to be deleted and recreated without losing data. To persist data, create directories on the local host and map the directory to the corresponding volume using the docker run command with the -v option. For example:
docker run -v local_directory:container_volume
Warning: If the volumes are not mounted from the local host, all data is lost when the container is removed.

DataStax exposes data volumes to preserve data. See Volumes and data directories for a list of exposed volumes.

Procedure

  1. Create a directory on the Docker host.
  2. Bind mount the local directory to the configuration file that will be persisted by starting the container with the -v option.

    Setting the DS_LICENSE environment variable signals your acceptance of the DataStax terms of service and is required for the software to start.

Example

Mounting a DDAC data volume

Mount the DataStax Distribution of Apache Cassandra™ (DDAC) data volume to the /ddac/data directory on the Docker host to ensure that the /data, /commit_logs, and /saved_caches directories will be available. Hosting the /var/lib/cassandra directory outside the container with the -v option allows the Docker container to be deleted and recreated without losing data.

docker run -e DS_LICENSE=accept --name my-ddac -v /ddac/data:/var/lib/cassandra