The post is also evidence that people are switching away from Vagrant to Docker because it simplifies the last step: deployment, Dawson said to me in an email. And Dockerfiles manage services with higher level abstractions. For example, a Vagrantfile specifies IP addresses where a Dockerfile uses links which are an abstraction above specific IPs. This makes deployment more generic and loosely coupled. Furthermore, Vagrantfiles manage a VM while Dockerfiles specify a loose set of services and their connections, a much lighter and more flexible abstraction.
The app Ajgaonkar prepared has three files: a
server.js and a
.gitignore file, which he set up as follows: The post further explains how
server.js pulls in the dependencies and starts an express app, “which is configured to store session information in Redis and exposes a single endpoint that returns a status message as JSON. ” For development, he ran both Node and Redis in the same container and used Dockerfile to configure it. Ajgaonkar used Ubuntu, one of the most commonly used base images with Docker. He used the apt-get command to add Python and Redis-server. The Redis server stores session information and Python is used to build the C-extension. Python is required by npm to build the C-extension. The post goes on to explain how to build and run a container in addition to explaining the workings of the run command. It covers how to start Redis in the container itself. Ajgaonkar uses Nodemon to “watch for changes in project files and restarts the server as needed.” Once the server is started with server.js, Nodemon detected the change and started the server. The process Ajgaonkar compares to builds described in other blog posts. Here are a few to review:
- Mark van Holsteijn of Xebia wrote a post earlier this week about using Deis, the new platform-as-a-service, to build a Node.js app that had originally been used on Cloud Foundry.
- Sean McGary has a tutorial for creating a container that runs a simple NodeJS web server.
- Luis Elizondo has a post about an environment with Docker, Node.js, MongoDB and Varnish.
An increasing volume of use case for Docker have started to surface. Docker has been lauded for its capabilities and wide use cases. The interest though, is as much about its technology as the needed shift for more flexible and lightweight services for distributed workloads. Docker reflects that shift and is symbolic of a new breed of services more suited to rapid application development.