Search code examples
dockerchef-infraiaas

Combining Chef And Docker


I am having hard time figuring how I should combine Chef and Docker to get the best of them.

Right now I am using Chef to automatically pull a docker image and create a container. But things get messy when I want to change the configuration inside the container.

I read about knife container but I didn't understand how one can bootstrap a container and a new vm (on Amazon for example) all together.


Solution

  • I would suggest that if all you want to do is manage Docker images/containers, that you don't really need Chef.

    Docker provides tools like:

    1. Fig (http://www.fig.sh/), which brings up multiple containers as one logical unit.
    2. Swarm (https://github.com/docker/swarm/), which allows you to abstract away the machines you have for deployments. For example, "My app needs 2GB of RAM, 1 CPU, 10GB of HD, which machine has available resources?"
    3. Machine (https://github.com/docker/machine), which allows you to create VMs in the cloud in pretty much any provider.
    4. A REST API (https://docs.docker.com/reference/api/docker_remote_api/), which allows you to remotely start/stop containers etc.

    In my opinion those suite of tools replace the need for Chef if all you're going to do is manage Docker images and containers.

    As someone already noted, don't change configs after a container has started. Better to make a new image or restart the container. You could also mount the configs external to the container and modify them there, then restart the container.