Docker Community Forums

Share and learn in the Docker community.

Docker container not persisting data on stop/start or when committing to another image on windows


(Krishna81m) #1

Docker does not seem to be persisting container (cassandra) data when I stop/start or when I commit/save to an image and run the image.

so I create few keyspaces and add some data, but when I stop/start container, it is gone whereas the schema exists?

Same with commiting the container as an image and running the image does not show any data.

– get an image and run it
winpty docker run -it --rm --net container:cassone a5260a399872 cqlsh
docker run -P -v //c//docker-workspace/shared:/shared f7ba11a14507

– login to container modify data
winpty docker exec -it 621b092bd27c bash

– create a new image from running container
docker commit -a “kris” -m “cassandra with schema and data -v3” 5e39051f249e krishna-cassandra-with-schema-and-data-v3

– get the new image
docker images

– run the new image in a new container << no cassandra data
docker run -P -v //c/docker-workspace/shared:/shared 5d9229545fb9
winpty docker exec -it dc06a73b24fd bash

– stop/start old container << loose cassandra data

(Krishna81m) #2

Apparently nodetool flush fixed the problem. Not sure if it sent the right stop/end signal to cassandra instance to give it a chance to flush the commit logs/memtables (memory) to sstables (file system/disk) when I said docker stop/commit container?

(Krishna81m) #3

Happening again, can anybody “help here”?

– run an image
docker run -v //c/docker-workspace/shared:/shared 66620dae02f5

– attach to container
winpty docker exec -it 51434fcc59db bash

– make a change to yaml file and save it
[root@51434fcc59db /]# vi /etc/cassandra/conf/cassandra.yaml

– commit changes to container as a separate image
docker commit -a “my” -m “cassandra with schema, data, thrift v2” 51434fcc59db my-cassandra-with-schema-data-thrift-v2

– run the new image
docker run -v //c/docker-workspace/shared:/shared f27a11694228

– connect to container
winpty docker exec -it f27a11694228 bash

– changes made to the new container image are lost ?

Repeated the same with pause=true and it does not work :frowning: .

(Krishna81m) #4

Rookie Docker/Cassandra mistake, had to flush before stopping the container, to persist the commit log to sstables.

Closing the ticket. Not sure if there are ways to hook scripts/command on docker stop container!