Recently, I was assigned on a new fun assignment to move away from a legacy Vagrant VM development environment. Our company was moving towards Docker and Kubernetes for all deployments and we wanted our development environment to reflect that.
We decided to not use Docker Compose. You might ask, “ OH MY GOSH, WHY NOT!?”. Docker Compose is a great tool for defining and running multi-container Docker applications. There is one configuration file in which you input information and instantly spin up multiple containers. Although, this is much easier, we decided to write our own scripts resulting in one final build script that essentially does the same thing as Docker Compose. We made a conscious decision to remove any additional layers of abstraction so this system is as explicit as possible, avoiding all magic and wizardry, promoting the best learning experience for our developers. In order to improve your understanding of Docker and communication between containers, I encourage anyone to set up a small practice project to play around with these scripts.
Let’s dive right into the code.
First, we need multiple containers. In our case, we are going to need an API, a SQL database, a Mongo database, a Redis database, and frontend container.