7

After doing

docker-compose up

and adding lots of stuff to the database etc, I stupidly did a

docker-compose down

to stop the dockers from running. Just found out it actually removes it all.

Is there a way to recover from this and get back the data containers?

FYI This is the config of the datastore in docker-compose.yml:

services:
  jira_datastore:
    image: busybox
    volumes:
      - /data
    entrypoint: echo "PSQL Data"
3
  • do you want to recover your data ? or learn how to stop your containers without removing them ? Commented Apr 19, 2017 at 7:21
  • I want to recover my data!
    – rept
    Commented Apr 19, 2017 at 9:21
  • 1
    If you stored the data in the container itself, then it's gone. This is why best practice to never store data in the container itself. You should always store data in volumes, or in externally-mounted directories. docs.docker.com/engine/tutorials/dockervolumes
    – Dan Lowe
    Commented Apr 19, 2017 at 17:28

3 Answers 3

4

I was able to recover the data, so it indeed is possible, in some cases to retrieve the data.

As mentioned in the question, I had a datastore which points to /data

By doing compose-up again and after this moving the data from the old to the new volume I got everything back!

1
  • you sir, are a Hero, thank you very much
    – fnaquira
    Commented Jul 29 at 4:49
1

This is not possible :-(. Next time do docker-compose stop to stop but not remove the containers. You could also save the data in a map shared on your host computer to make the data persistent, for more info on this: https://docs.docker.com/engine/tutorials/dockervolumes/

1

So as per docker-compose docs (https://docs.docker.com/engine/reference/commandline/compose_down) the data is not really deleted. For unnamed volumes the new up command cannot connect back to them hence ends up recreating a new volume, your old data sould still reside in DOCKER_HOME/volumes.

Found my data by looking at the change timestamp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.