Bert Alfred
Bert Alfred

Reputation: 511

Docker deployment best practices

I am just beginning my journey to docker and am trying to put together the image of how to deploy docker to production instances in the cloud. We use ansible for all of our applications deployments currently. However, when I look for information on deploying docker containers I see either references to swarm and kubernetes or what appears to be manual deploys via ssh.

So, my noob question is, how do you deploy docker to your hosts in the cloud? Is there any reason to use ansible? (They have a plugin.) It seems like maybe swarm or kubernetes may just take care of that for us.

Upvotes: 2

Views: 2319

Answers (2)

Manish Joshi
Manish Joshi

Reputation: 3770

I believe the answer to this question varies depending on what your application's deployment requirement are.

Case 1) Your application's deployment is straight-forward, all you need is to deploy docker container.

Solution 1) You don't really need a configuration management tool to manage your deployment in this case I believe, you can pretty much set up a Jenkins job as suggested here.

Case 2) Your application's deployment require a few of configuration to be done in the docker host instance as well, maybe you need to setup some monitoring agent, setup some logrotate etc.

Solution 2) You should use ansible/chef to setup your host environment and also deploy docker container using it. Now here docker container deployment could be like the normal docker run or you can go with recommended docker swarm way, if you have more than 1 application to deploy and you want your docker host instance to be used effectively memory or cpu wise. Not to mention there are multiple other benefits of using swarm, which you can check if they are applicable for you.

Case 3) Your application's deployment require you to modify some kernel level parameters, maybe it needs some modifications in ulimit parameter etc.

Solution 3) Docker swarm has some limitations when it comes to kernel configuration options. You can participate in the discussion here. In this case you might have to go in the classic docker deployment way, i.e. docker run until support is added for those configurations in docker swarm.

Upvotes: 1

Romain Bigeard
Romain Bigeard

Reputation: 106

I worked on a container based platform 4 years ago and at the time, we used Ansible to deploy containers as orchestration frameworks were non existent.

Nowadays, I would recommend using an orchestration framework (Kubernetes, Docker Swarm, Openshift, etc.) which provides features such as ingress load balancing, lifecycle management, persistent volume management etc.

There are many ways to run containers in public clouds, some implementing orchestration frameworks like Kubernetes, some implementing their own frameworks: azure acs/aks, AWS ECS, Google Container Engine, etc. Docker machine can provision docker swarms in public clouds as well. What's interesting with those is that the underlying VMs are either hiddent or managed for you.

There are many many ways to do it but just using Ansible will be limited to spinning up containers on existing VMs that you'll have to provision and manage.

Upvotes: 2

Related Questions