Docker Community Forums

Share and learn in the Docker community.

Dockerize A Web Application With Multiple Containers


(Meleiyu) #1

I’ve watched and read quite a bit about docker and used it as a mini-vm of sorts in the past. I now want to try my hand at dockerizing an exisint Django application. It currently runs on a VM with mysql, apache2, python/django as the specific services.

I’ve found guides online to handle this but they all use Ubuntu as a base image which to me seems no different than using a VM.

I’ve seen examples where python/django/bottle would be running in a container and nginx would run in another. And perhaps mysql in yet another container.

However, I haven’t found any viable examples for doing this with apache. In the nginx examples, the nginx config needs to be set up a certain way with ProxyPass and some other settings. I’ve been unable to find an example apache configuration though I assume the structure of how the containers communicate would be the same.

Now in the nginx example, bottle was being used rather than django. From what I understand, bottle would listen on port 8000 and nginx on 80. Only port 80 would be published from the nginx container, and the requests would be passed to the bottle container.

Would a Django setup similar to this be possible? Django’s runserver command isn’t generally used in production so I’m not sure how the same could be achieved.

As for multiple container setups, since I am new to these I’m confused as to how they are grouped. In the example setup with nginx and python/bottle, the two containers communicate with one another and are obviously on the same host. But how are they grouped so that they are isolated from any other containers running on the host, though still able to communicate?

Any input would be appreciated. I hope to begin using more of docker’s capabilities rather than just running it as a mini VM.

Thanks