Saltear al contenido principal
Building With Docker

Building with Docker

  • Blog

Setting up a working infrastructure is the most tedious and time-consuming issue to create a working environment for software. That is, unless you have a dedicated server running Docker. Then it’s mostly about typing a few lines on a console.

 

What is Docker?

Essentially, Docker generates small packages that run single processes (keep this idea in mind, we’ll revisit it later). Hosting a mysql database, for example, becomes as simple as entering the following command:

docker run -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

Yes, that’s it. This will instantiate a MySQL container on port 3306, with a single root user. However, once we stop the container, all data will be lost. If it’s necessary, Docker includes support to manage data, and persist information between sessions. But, think about it, do you really need it? You have the opportunity to define and re-define each container so, for example, a script to create database, populate it with data and configure could do the trick. You can have clean databases with each execution!

 

One container = One process

The design patterns behind Docker enforce this rule, since the effort to establish communication between containers is negligible. One container holding the database will easily allow for another instance launching the back-end to retrieve data. In order to avoid bad practices, the daemon will kill the additional processes run within the container. The aim is not having an out-of-the-box configured environment (you should check Ansible/Chef/Vagrant for that!), but a single “building block” that can be shared with your team or the community.

 

Dockerfiles

What good is a tool if you cannot tune it to your specific needs? Every container in Docker is defined in a single file, from which you can generate a new the same image. You could set up the necessary instructions to retrieve code of your own, then set up a package and start that very image. Continuous Integration does not look that painful now, does it?

 

Docker the docker to docker

Now that you have the blocks, how about scaling up your content? Docker Swarm allows to control several Docker instances together as a single cluster. Generate the containers that your application needs, and now you have the option to use it as a development environment, increasing the amount of images as required, or even use Docker as a deploy engine directly to your users.

 

Written by Álvaro G. Cachón

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Volver arriba