2

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.

idoshamun
  • 1,125
  • 9
  • 21
  • What does it mean to "change the configuration inside the container"? How? – BlackBear Feb 21 '15 at 21:07
  • 2
    Don't change the configuration within the container. Design the container to use environment variables, which you set from Chef. – Mark O'Connor Feb 22 '15 at 12:30
  • If you want to use chef within the container checkout the docs: https://docs.chef.io/containers.html and https://docs.chef.io/plugin_knife_container.html – Mark O'Connor Feb 22 '15 at 12:31
  • I want to provision a vm with a docker container that runs replicated mysql and set the master server using Chef. Replication is set using the my.cnf file. – idoshamun Feb 22 '15 at 19:51

1 Answers1

1

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.

ryan1234
  • 7,237
  • 6
  • 25
  • 36