The Dockerfile simply defines what your Image should do. A Docker image is defined in a file called a ‘Dockerfile’, which is very similar in function to a Vagrantfile. As you may have guessed from the header above, you create containers using Docker images. Now that we know what Docker containers are, we need to understand how they’re created. This is a very simplistic explanation of how Docker works and if you’re interested in a more in-depth explanation, Docker provides a fairly thorough overview here: Docker Images For the purpose of this article, you can think of Docker as a VM running on your machine and each container that you instantiate runs on the VM and gets its own sandbox to access necessary resources and separate it from other processes. In my example, I’m now running multiple containers where I only had to run a single Vagrant VM… how is this a better solution? Well, the way that Docker implements its containers makes it much more efficient than an entire VM.ĭocker at its heart runs on a single, very slimmed down host machine (on OS X). One Host to Rule Them AllĪt first running multiple containers seems like it would be MORE resource intensive than Vagrant, which only runs a single VM. NOTE: In my example below I’m going to combine the PHP service and the Apache service into one container for simplicity and since logically there isn’t a compelling reason to separate them. Docker then provides networking between those containers to allow them to talk to each other. Docker allows you to separate those services and run each service in its own container which is much more lightweight than a full VM. In Vagrant, I would have built an Ubuntu VM and had Puppet install and configure these services on that machine. We need an application server to run PHP, a web server (like Apache or nginx) to serve our code, and a database server to run our MySQL instance. So what are Docker containers? Well, if we’re developing a PHP application, there’s a few things that we will need. Docker on the other hand can run only the services you need by utilizing containers. This means that for each project, you have a full stack VM running which is very resource intensive. What does this mean practically? Well, if you’re familiar with Vagrant you will know that Vagrant helps you create one large monolithic VM and installs and configures (through configuration management tools like Puppet or Chef) everything that your Application needs. Docker is a container based solution, where you build individual containers for each of the services you require for your application. Let’s start off with the basics of Docker and how it differs from Vagrant. I’ll tell you now, the transition to Docker was not as difficult as I had built it up to be in my mind. I’ve been using Vagrant for years to spin up a unique development environment for each of the client projects that I work on and it works very well, but does have some shortcomings that I was hoping that Docker would alleviate. I’ve personally been putting it off for a long time, but since I discovered that Docker had released a “native” OS X client I decided it was finally time to give it a go. Moving from Vagrant to Docker can be a daunting idea.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |