Nowadays when people setup and configure services, probably nobody will enjoy doing it in a manual way.
Here comes a new question. How do you automate the process, and make it fast and reliable?
Wrap up some ssh scripts? Leverage CM(configuration management tools) like chef, ansible, or pupet? Use docker run? It’s great that we now have many options. But, as you may guess, not all of them are equally good.
You want a headache-free solution, right? And you also want it real quick, do you? Then You Can Not Miss docker-compose! Here are some useful tips and lessons learned using docker-compose.
I’m not here to argue with you that docker-compose is the best for all scenarios. Definitely there are some, which we can not or should not dockerize. Well, I still insist that it’s capable for most cases.
CM is good, but docker/docker-compose is just better for env setup. (Read: 5 Common Failures Of Package Installation). Not convinced, my friends? Give it a try and challenge me now!
With plain docker facility, we can setup envs like below.
docker run --rm -p 8080:8080 \ -h mytest --name my-test\ -v /var/run/docker.sock:/var/run/docker.sock \ --group-add=$(stat -c %g /var/run/docker.sock) \ jenkinsci/docker-workflow-demo
But… The command is just too long, isn’t it? What if you need to start multiple different containers? You may easily mess it up, right?
Show time for docker-compose, an advanced version of docker run.
Just one single command, docker-compose up -d! We can run the same deployment process against another new environment within just a few seconds. Beautiful, isn’t it?
Here are my lessons learned using docker-compose.