Coder Social home page Coder Social logo

chef-cookbook-docker_compose's Introduction

Docker Compose Cookbook

The Docker Compose Cookbook is a library cookbook that provides custom resources for use in recipes.

Requirements

  • Working Docker installation. You might want to use the excellent docker Cookbook to provision Docker.

Usage

Place a dependency on the docker-compose cookbook in your cookbook's metadata.rb

depends 'docker_compose', '~> 0.0'

Create a Docker Compose file for the application you want to provision. A simple Compose file that uses the official nginx Docker image looks like this:

version: '2'
services:
  web_server:
    image: nginx
    ports:
      - "80:80"

Then, in a recipe:

include_recipe 'docker_compose::installation'

# Provision Compose file
cookbook_file '/etc/docker-compose_nginx.yml' do
  source 'docker-compose_nginx.yml'
  owner 'root'
  group 'root'
  mode 0640
  notifies :up, 'docker_compose_application[nginx]', :delayed
end

# Provision Compose application
docker_compose_application 'nginx' do
  action :up
  compose_files [ '/etc/docker-compose_nginx.yml' ]
end

Attributes

  • node['docker_compose']['release'] - The release version of Docker Compose to install. Defaults to a sane, current default.

  • node['docker_compose']['command_path'] - The path under which the docker-compose command should be installed. Defaults to /usr/local/bin/docker-compose

Recipes

default

The default recipe is simply an alias for the installation recipe.

installation

The installation recipe installs the docker-compose binary by downloading it from the vendor's servers, as described in the official Docker Compose documentation.

The path to which the docker-compose command is installed can be configured via the node['docker_compose']['command_path'] attribute.

Resources

docker_compose_application

The docker_compose_application provisions a Docker application (that usually consists of several services) using a Docker Compose file.

Example

docker_compose_application 'nginx' do
  action :up
  compose_files [ '/etc/docker-compose_nginx.yml', '/etc/docker-compose_nginx.additional.yml' ]
  services ['nginx']
  remove_orphans true
end

Parameters

  • project_name - A string to identify the Docker Compose application. Defaults to the resource name.

  • compose_files - The list of Compose files that makes up the Docker Compose application. The specified file names are passed to the docker-compose command in the order in which they appear in the list.

  • services - The list of services to start or stop. Defaults to all services that are specified in the Compose files.

  • remove_orphans - Remove containers for services not defined in the Compose file.

Actions

  • :up - Create and start containers. Equivalent to calling docker-compose up with the Compose files that were specified using the compose_files parameter.

  • :down - Stop and remove containers, networks, images, and volumes. Equivalent to calling docker-compose down with the Compose files that were specified using the compose_files parameter.

License & Authors

Authors

License

Copyright (c) 2016 Sebastian Boschert.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

chef-cookbook-docker_compose's People

Contributors

sboschert avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.