Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose in production?

I plan to use docker to build my dev and production environment. I build Django based app.

On dev I use docker-compose to mange all local containers. It's a nice and convenient solution. I run Django, 3 celery queues, rabbitmq, 2 postgresql DBs.

But my production environment is quite different. I need to run gunicorn and nginx. Moreover DBs will be ran using AWS RDS. Of course Django app will require more stuff, like different settings file or more env vars.

I'm wandering how to divide it. Should I docker-compose there as well? That will require separate files for dev and prod, maybe more in future for staging etc... If yes, how to deploy it? Using Jenkins, pull, restart all using compose?

Or maybe I should use ansible to run docker commands directly? But then I have no confidence that my dev is the same as live and it's harder to predict its behaviour.

I like the idea of running compose files on all environments, but I'm not sure if maintaining multiple files for different environments is a good idea. Dev requires less env vars and less configuration. I can use env file to set all of them on production. But should I keep my live settings in the se repo? Previously I was setting all env vars while provisioning and this was separate process. Now it looks like provisioning and deploy are the same? Maybe this is the way with Docker?

like image 843
tunarob Avatar asked Nov 15 '15 19:11

tunarob


People also ask

Is it OK to use Docker compose in production?

Docker Compose is an excellent tool for optimizing the process of creating development, testing, staging, and production environments. With Docker Compose, you'll use a single file to build your environment instead of several files with complex scripts with a lot of branching logic.

Is Docker compose deprecated?

You can still find Docker Compose V1 in the `master` branch. Compose V1 is marked as deprecated, and we'll begin patching only high-severity vulnerabilities or fixing critical bugs until the next milestone. Developers can continue to alias docker-compose to use docker compose.

When should I use Docker compose?

This is where you can relate this example to Docker, where Docker Compose can connect different containers as a single service. Docker Compose is used for running multiple containers as a single service. Each of the containers here run in isolation but can interact with each other when required.

Is Docker compose for local development?

Introduction to Docker ComposeYou can use Docker Compose to define your local development environment, including environment variables, ports you need accessible, and volumes to mount. Everything is defined in docker-compose.


1 Answers

Using http://docs.docker.com/compose/extends/#multiple-compose-files you can keep all the common stuff in a docker-compose.yml and use docker-compose.prod.yml to add extra services, change links, environment, and ports.

like image 102
dnephin Avatar answered Sep 28 '22 20:09

dnephin