I am just really getting into Docker. I want to put my existing application infrastructure into containers to provide a consistent and isolate environment, and easier deployment.
My Setup
There are a number of services/daemons that I are running (Redis, ES, PG, NGINX) as well as a few workers (need to talk to PG and Redis). I have 3 ruby web application services and a faye service which all need to talk to Redis, PG and ES. NGINX will need to reverse proxy to the applications.
Container strategy
First thing I want to know is which strategy would you use with docker and these services.
Dockerfile
Would/could you make a single Dockerfile for all containers, or split them up? i.e. Redis-Dockerfile, Web01-Dockerfile etc.
Development vs Production
In Development I want to have file changes instantly update on the containers (i.e. path mounted in the containers from the host FS). The mount point could differ from developer to developer. How would you set this up?
In production, I can either clone the application repos on the host machine and mount in the VMs or I could clone the application code inside the container itself.
I know of the -v flag for mounting volumes, so I'd imagine you can setup some environment variables to make host mount points configurable.
Container strategy: this is a frequently asked question. It really depends what you want to do with your application.
Dockerfile: you need one Dockerfile per image. So, if you make a "all-in-one" container, it's one Dockerfile; if you split the app in multiple containers with different roles (Redis, DB, Web...) that's as many different Dockerfiles.
Dev vs Prod: it really depends on the language/framework/etc. that you use.
ADD
followed by expensive build/dependency steps)./myapp
. In the development Dockerfile, you will declare /myapp
to be a VOLUME
, and the developer will be expected to bind-mount their local copy of the source to /myapp
. In the production Dockerfile, you will use ADD
to copy the source to /myapp
. There will be also minor differences in the build process.The last method is not ideal (since it's better when dev and prod environments are as close as possible!) but in some cases (when building a new container is very long) it helps a lot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With