# Destroying docker container does not destroy the database?

**URL:** https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411
**Category:** Self-hosting
**Created:** [March 16, 2015, 9:18pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411 "2015-03-16T21:18:41Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![jamesmarkcook](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesmarkcook/32/168563_2.png) [@jamesmarkcook](https://meta.discourse.org/u/jamesmarkcook)
#### Post date: [March 16, 2015, 9:18pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/1 "2015-03-16T21:18:42Z")

</div>

So…wait for it…I destroyed my postgres and web\_only containers, bootstrapped them again and hang on..what’s that? My forum is still there?!

I’m quite confused and I’m not sure what’s going on. I used one of the import scripts to import some data, but now I want a fresh install to run the script again (something wasn’t perfect first time round).

However, I cannot accomplish that. Does anybody have any ideas how my data can still be there after destroying the Postgres container and re-boostrapping?

FYI, I’m using a custom docker image but all it does extra from the main docker one is change the folder directory names and install some linux dependencies for mysql.

I’m wondering if somehow I’ve committed the data to my docker image on docker hub. But even that is just an image with my personal fork of Docker. I’m not committing postgres stuff. Hmm…

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 16, 2015, 9:24pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/2 "2015-03-16T21:24:05Z")

</div>

By design, all data is stored out of the container in a volume. If you insist on nuking everything, destroy your container, `rm -fr /var/discourse/shared/standalone` and re-boostrap.

If you run:

```plaintext
cd /var/docker
git pull
./launcher rebuild app

```

you will see the actual docker command we run.

---

<div class="post-metadata">

### Author: ![brahn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/brahn/32/109267_2.png) [@brahn](https://meta.discourse.org/u/brahn)
#### Post date: [March 16, 2015, 9:33pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/3 "2015-03-16T21:33:27Z")

</div>

> [@sam](#):
>
> destroy your container, `rm -fr /var/discourse/shared/standalone`

not to be confused with the command `./launcher destroy app` though right?

---

<div class="post-metadata">

### Author: ![jamesmarkcook](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesmarkcook/32/168563_2.png) [@jamesmarkcook](https://meta.discourse.org/u/jamesmarkcook)
#### Post date: [March 16, 2015, 10:13pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/4 "2015-03-16T22:13:23Z")

</div>

> [@sam](#):
>
> By design, all data is stored out of the container in a volume.

Thanks Sam. I don’t think I ever would have figured that one out.

Is this something specific to the Discourse install, or is this a Docker feature?

But yes, @brahn has a point. Shouldn’t `./launcher destroy app` do this for you?

If not, I think it’s at least something to highlight on the install guides for anyone following along, as the destroy command would give the impression that you’re starting fresh.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [March 16, 2015, 10:34pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/5 "2015-03-16T22:34:04Z")

</div>

Suggested reading:

[https://meta.discourse.org/t/advanced-troubleshooting-with-docker/15927](https://meta.discourse.org/t/advanced-troubleshooting-with-docker/15927)

---

<div class="post-metadata">

### Author: ![brahn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/brahn/32/109267_2.png) [@brahn](https://meta.discourse.org/u/brahn)
#### Post date: [March 16, 2015, 10:39pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/6 "2015-03-16T22:39:24Z")

</div>

> [@jamesmarkcook](#):
>
> But yes, @brahn has a point. Shouldn’t ./launcher destroy app do this for you?

Oh sorry, I didn’t mean to imply that the launcher destroy should do that. I just meant to point out that using the word destroy when talking about `rm` the shared data/volume could have been confusing 😄

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 16, 2015, 10:42pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/7 "2015-03-16T22:42:58Z")

</div>

It is a bit confusing but a key concept that you need to keep in mind with our Docker design is that containers are throw-away. I always wanted a trivial to recover scenario, for example you can even recover data if docker completely fails and so on.

destroy is a somewhat scary word, but it does really destroy the container, which you can rebuild or start again a-fresh.

---

<div class="post-metadata">

### Author: ![jamesmarkcook](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesmarkcook/32/168563_2.png) [@jamesmarkcook](https://meta.discourse.org/u/jamesmarkcook)
#### Post date: [March 16, 2015, 10:51pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/8 "2015-03-16T22:51:27Z")

</div>

Thanks for your replies. I was already pretty confident with the Docker setup, I just wasn’t aware of the symlinked volumes and the data living on the host. Now I know! 🙂

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [September 18, 2018, 5:33pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/9 "2018-09-18T17:33:21Z")

</div>



---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [September 18, 2018, 5:37pm UTC](https://meta.discourse.org/t/destroying-docker-container-does-not-destroy-the-database/26411/10 "2018-09-18T17:37:29Z")

</div>


