DevOps Basics : Running Docker in production
Docker is a containerization technology very "trendy", which means a lots people are interested about it, using it or trying it.
Very often, when I engage the conversation about containerization I asked this two questions, in this order:
- How many of you are using containers (Docker or others technology)?
- How many of you are using this containerization technology in production?...
When I talk about production, it means for me: High Availability, SLA, Disaster recovery, and more... It cannot be a simple virtual machine running your containers.
It's funny to see the big drop in the room when I asked the second question.
In my previous articles, I showed you how it's very simple to deploy a Docker environment, but what about to run your containers in a real production environment?
In few words, if you want to run your Docker containers in a real production environment you need multiple tools and complex architectures are possible.
That's why we just created: Azure Container Service (ACS).
I will show you in this article, how you can easily deploy this service and use it to deploy you containers.
From the Azure gallery, search for Azure Container Service:
In the first panel you have to specify some basics options:
In this example I created a new ssh keys pair thanks to ssh-keygen.exe and paste the .pub file on the SSH public key field
For the next, step you have to specify the H.A framework that you want to use, in my case I prefer to use DC/OS :
Next, you have to specify the numbers of Agent and Master that you want, depends on the size of the environment that you want. In my demo I want a small environment to test it :
The DNS prefix is the endpoint accessible from the outside for your environment.
Finally, validate your template and click on create.
You should see on your dashboard the deployment like this :
Connecting to your environment
When your environment is ready, you have to initiate a SSH tunnel to use it.
Like me, if you are using Windows, you can do that simply with putty.exe.
You have all the information here : https://azure.microsoft.com/en-us/documentation/articles/container-service-connect/
If you want to know your endpoints, you can check through the portal, you should have two public IP address resources, one master and one agent. To initiate the connection, you need the master DNS name, in my case it’s: acscanitpromgmt.eastus.cloudapp.azure.com, so if I want to initiate the SSH connection I will enter the username + the endpoint, your username will be you DNS prefix: email@example.com
When the connection is initiated in Putty.exe you have:
If everything works well, you should be able to browse the two main tools:
- https://localhost (DC/OS)
- https://localhost/marathon (Marathon)
In one word, DC/OS is where you will manage your clusters and Marathon where you will orchestrate your containers (Start, Stop, Scale, etc...)
Deploying your application
Finally, let's try to deploy one application in our cluster.
To do that, go on the Marathon portal and click on Create Application:
Enter the following information:
- ID : canitpro
- CPU : 0.1
- Memory : 16Mb
- Image : julienstroheker/helloworldguys
- Network : Bridged
- Container Port : 80
- Protocol : tcp
Next, you can click on "Create Application", you should see your application on the portal:
When it's running, you can go back on the DC/OS portal to see the result and you have more resources available in your cluster:
Finnaly, you can see the result on your agent endpoint : https://acscanitproagents.eastus.cloudapp.azure.com/ in my case:
With ACS, you can deploy in few clicks a full production wise cluster Docker in 10 minutes ! Azure will deploy for you, a bunch of VMs with all the tools installed and configured in best practices on it.
Resources and more info:
Thanks for reading.