🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🔧 Programmierung 🕛 kürzlich 5 Min Lesezeit
0

Working with Docker Volumes

↗ Quelle (dev.to)
🗣️ Stimme:

Working with Docker Volumes

Docker Volume is a mechanism in Docker that allows you to persist data even after a container is deleted or recreated. It provides a way to store data outside of the container's filesystem, so that data is not lost when the container is restarted or deleted.



Why do we need Docker Volumes?

When you run a container, it has its own filesystem, which is ephemeral. This means that any data written to the container's filesystem will be lost when the container is deleted or restarted. Docker Volumes provide a way to decouple the data from the container's filesystem, so that data can be preserved even when the container is recreated.



How do Docker Volumes work?

A Docker Volume is a directory that is shared between the host machine and a container. When you create a volume, Docker creates a directory on the host machine, and mounts it to a directory inside the container. This allows data to be written to the volume, which is persisted even when the container is deleted or recreated.



Example Scenerio: Using Docker volumes with a NoSQL Database (Apache Cassandra)

In this scenario, we will use Docker to create and manage a single-node Cassandra cluster. We'll create a keyspace, delete the container, and then recover the keyspace on a new node in another container using Docker volumes. Follow the detailed steps below:





Explanation:



docker volume create: Command to create a Docker volume.

--driver local: Specifies that the volume should use the local driver.

--label example=cassandra: Adds a label to the volume for easier management and identification.

cass-shared: The name of the volume.

Step 2: Run a Cassandra Container

Next, run a Cassandra container and mount the previously created volume to the container.




CODE
docker run -d \
--volume cass-shared:/var/lib/cassandra/data \
--name cass1 \
cassandra:2.2








Explanation:



docker run -it --rm: Runs the container interactively and removes it after exit.

--link cass1:cass: Links the client container to the cass1 container.

cassandra:2.2: Uses the Cassandra image version 2.2.

cqlsh cass: Runs the CQLSH command line tool to connect to the Cassandra server.

Now you can inspect or modify your Cassandra database from the CQLSH command line. First, look for a keyspace named docker_hello_world:




CODE
select *
from system.schema_keyspaces
where keyspace_name = 'docker_hello_world';








Explanation:



create keyspace: Creates a new keyspace.

docker_hello_world: The name of the keyspace.

with replication = { 'class' : 'SimpleStrategy', 'replication_factor': 1 }: Specifies the replication strategy and factor.

Verify the keyspace creation:




CODE
select *
from system.schema_keyspaces
where keyspace_name = 'docker_hello_world';








Explanation:



quit: Exits the CQLSH shell.

docker stop cass1: Stops the cass1 container.

docker rm -vf cass1: Removes the cass1 container forcefully and deletes associated resources.

Step 6: Test Data Recovery

Create a new Cassandra container and attach the volume to it.




CODE
docker run -d \
--volume cass-shared:/var/lib/cassandra/data \
--name cass2 \
cassandra:2.2








Connect to the new Cassandra container using CQLSH.




CODE
docker run -it --rm \
--link cass2:cass \
cassandra:2.2 \
cqlsh cass






Query the keyspace to verify data persistence.




CODE
select *
from system.schema_keyspaces
where keyspace_name = 'docker_hello_world';








Explanation:



quit: Exits the CQLSH shell.

docker rm -vf cass2: Removes the cass2 container forcefully.

docker volume rm cass-shared: Deletes the cass-shared volume.



Summary

In this scenario, we have:




  1. Created a Docker volume.

  2. Ran a Cassandra container with the volume mounted.

  3. Connected to the Cassandra container using CQLSH.

  4. Created and verified a keyspace.

  5. Stopped and removed the Cassandra container.

  6. Tested data recovery by creating a new container and verifying the keyspace.

  7. Cleaned up by removing the containers and volume.



This demonstrates how to use Docker volumes for data persistence in a Cassandra database, ensuring that data remains available even after the container is deleted.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Working with Docker Volumes

Thematisch verwandte Begriffe: Working, with, Docker, Volumes · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...