Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A Docker workflow for a developers team

Tags:

docker

In our team we currently use vagrant as a development environment. Now I want to replace it with docker, but I can't understand the team workflow with it.

This is what confuses me: with vagrant I create a project repo with a Vagrantfile in it, and every developer pulls a repo and runs vagrant up. If the project needs some changes in environment, I edit Vagrantfile, chef recipe or requirements-file, and developers must run vagrant provision to get an updated environment.

But with docker I see at least two options:

  • create a Dockerfile and put it in repo, every developer builds an image from it. On every change they rebuild their own image.
  • build an image, put it on server, every developer pulls it and run. On every change rebuild and image on server (maybe some auto-rebuilds on server and auto-pull scripts).

Docker phylosophy is 'build once, run anywhere', but the same time we have a Dockerfile in repo... What do you think about it? How do you do this in your team?

like image 565
Alex Danilenko Avatar asked May 22 '14 06:05

Alex Danilenko


Video Answer


1 Answers

Docker is more for production as for development

Docker is a deployment tool to package apps for production (or tests environments). It is not so much a tool for development. It is meant to create an isolated environment to run your already developed application somewhere on a server, the cloud or your laptop.

Use a Dockerfile to document the packaging

I think it is nice to have a Dockerfile in your project. Similar to a Vagrant file, it is a kind of executable documentation which describes how your production environment should look like. Somebody who is new to your project could just run the file and will get a packaged and ready-to-run container. Cool!

Use a registry to integrate Docker

I think you should provide a (private) Docker registry if you integrate Docker into your (CI) workflow (e.g. into test and build systems). A single repository to store validated and tested images of all your products will definitely speed-up your time to create new test or production systems (e.g. to scale your app or to setup an installation for a demo or a customer). If your product is open source, consider the public Docker index so people could find your stuff there. You can configure your build system to create a new Docker image after each (successful) build and to push it to the registry. Since the images are layered (and those layers are shared), this will be fast and will not take to much disk space.

If you want to integrate Docker in your development, I don't see so much possibilities:

  • You can create a repository with final images (as described before)
  • Or you can use Docker images to develop against them (e.g. to run a MongoDB)

Maybe you have a team A which programs against the API of team B and always needs a running instance of team B's product. Then you could package this product into a Docker image and share it with team A. In this case, team B should provide the image in a repository (and team A shouldn't take care how to build it and use it as a blackbox).


Edit: If you depend on many external apps

To make this "team A and team B" thing more clear: If you develop an app against many other tools, e.g. an app from another team, a MongoDB or an Elasticsearch, you can package those apps into Docker images, run them (locally) and develop against them. You will also have a good chance to find popular apps (such as MongoDB) in the public Docker Index. So instead of installing them manually, you can just pull and start them. But to put together an environment like this, you will need Vagrant again.


You could also use Docker for test environments (build and run an image and test against it). But this wouldn't be a replacement for Vagrant in development.

Vagrant + Docker

I would suggest to use both. Provide a Vagrantfile to build the development environment and provide a Dockerfile to build the production environment.

Also take a look at http://docs.vagrantup.com/v2/provisioning/docker.html. Vagrant has a Docker integration since a while, so you can create Docker containers/environments with Vagrant.

like image 106
Thomas Uhrig Avatar answered Oct 05 '22 19:10

Thomas Uhrig