Running Discourse Docker container within another Docker container


(Hourback) #1

Hi, all.

Since Discourse introduced me to Docker, I sort of can’t get enough of it. As a result, I’m trying to install Discourse via Docker within another Docker container.

I’m stuck at the point where I run ./launcher bootstrap app. The cursor just blinks indefinitely until I Ctrl+C. I double-checked that docker and postfix are running (I’m running the latest Ubuntu image on Docker Hub). Any ideas?

(Régis Hanol) #2

Wondering: why would you want to run the Discourse container inside another Docker container?

(Hourback) #3


Good question! When I have a chance later today, I’ll try to remember exactly and get back to you.

(Salman, Freelance Developer) #4

You probably want to run multiple containers not embedding containers inside containers.

(Hourback) #5

I think this is what happened:

My goal is to have what @rubydoob suggests: to have multiple containers running on the same host. However, I wanted the host to be a Docker container.

I’m on Windows at work. I am impressed with how boot2docker performs. However, I was leery of basing a new environment on whatever boot2docker is (a barebones Virtualbox Linux VM?). I was afraid of gotchas that might exist due to it not being a full-blown Linux host. So, I thought the next best thing would be to create a Linux environment for myself based on an official Ubuntu image for Docker.

If there’s some theoretical reason why the nested container thing won’t work, then I’m fine with resigning myself to putting my multiple containers on the boot2docker environment. I won’t love it as much as I would love the nested containers! :smile: But if it works, I’ll get over it soon enough.

BTW, my use case right now was to run multiple standalone Discourse containers with an Apache proxy in front of them all.

(Régis Hanol) #6

@sam did all the work on the discourse docker container, maybe he has an answer?

(Sam Saffron) #7

My answer is, this is probably a very terrible idea.

This is not a technique I would use nor something the docker team would recommend.

(Aizan Fahri) #8

No you cannot do that. To run Docker, you need to have access to kernel and few of its capabilities (e.g., cgroups). Inside a Docker container, the kernel, figuratively speaking, doesn’t exist anymore so you can’t spawn another container atop the existing container.

TL;DR no you can’t. However, to do multiple encapsulation, you might want to give VM a try with this setup:

Docker inside a VM inside the host, which should satisfy your need as stated above.

(lid) #9

To run multiple Docker containers all you need is a single docker setup on a single compatible host machine.

In your case you physical computer is a windows 8 machine with VirtualBox

You can have Virtual Box running any os that support docker

In a single virtual machine guest instance, you can run multiple docker containers, theoretically each container can run a different discourse setup. each docker container gets its own network interface, and isolated environment.

Even if it is possible to running docker inside a docker, it wasn’t designed for it , and your usage case does not even requires it.

This article can be a starting point

(Michael Brown) #10

What you need to do is expose the host docker daemon’s docker to the “managing” container.

Then you can run docker commands from inside that container that actually take effect on the host.

We don’t necessarily support this.

Also be careful: having access to the docker daemon is equivalent to having root access on the host.