Home

Awesome

Crowdr License Current Version

Extremely flexible tool for managing groups of docker containers.

Features

Installation

Quick-start guide

Configuration

Commands

Hooks

Features

Installation

Become root (for example with sudo -i) and execute:

# curl -s https://raw.githubusercontent.com/polonskiy/crowdr/master/crowdr > /usr/local/bin/crowdr
# curl -s https://raw.githubusercontent.com/polonskiy/crowdr/master/completion > /etc/bash_completion.d/crowdr

Yes, that's all. No need for additional libraries or execution environments.

Quick-start guide

Example

The following example runs simple but complete Wordpress installation on Docker which contains:

It uses only official docker containers, so it can be used easily to play with crowdr.

  1. Create empty directory and cd into it.

  2. Create crowdr.cfg.sh file (crowdr configuration file) with following content.

#!/bin/bash

crowdr_project="example01"
crowdr_name_format="%s-%s"

net_name=${crowdr_project}
wordpress_db_host=$(crowdr_fullname wordpress-db)
mysql_root_password=secret-pass
wordpress_db_name=wordpress
wordpress_db_user=wordpress
wordpress_db_password=secret-pass
wordpress_port=8080

crowdr_config="

# Wordpress MySQL database.
wordpress-db image mysql:5.7.10
wordpress-db before.run create_network
wordpress-db net ${net_name}
wordpress-db volume $(crowdr_fullname wordpress-db):/var/lib/mysql
wordpress-db env MYSQL_ROOT_PASSWORD=${mysql_root_password}
wordpress-db env MYSQL_DATABASE=${wordpress_db_name}
wordpress-db env MYSQL_USER=${wordpress_db_user}
wordpress-db env MYSQL_PASSWORD=${wordpress_db_password}

# Wordpress web application on Apache webserver.
wordpress-web image wordpress:4.3.1
wordpress-web net ${net_name}
wordpress-web volume $(crowdr_fullname wordpress-web):/var/www/html
wordpress-web env WORDPRESS_DB_HOST=${wordpress_db_host}
wordpress-web env WORDPRESS_DB_NAME=${wordpress_db_name}
wordpress-web env WORDPRESS_DB_USER=${wordpress_db_user}
wordpress-web env WORDPRESS_DB_PASSWORD=${wordpress_db_password}
wordpress-web publish ${wordpress_port}:80

"

create_network() {
    docker network create ${net_name} &> /dev/null
}

NOTE: Please replace the passwords with stronger ones if you are going to use this example for something more serious than exploration of crowdr capabilities.

The format of configuration file is explained in Configuration section.

  1. Create and start all containers with crowdr run.

  2. Open your browser and go to localhost:8080 to check if it works.

  3. Stop containers with crowdr stop.

  4. Start containers again with crowdr start.

  5. Check other commands.

  6. If you want to remove this example entirely from your host OS, execute:

Configuration

Format of configuration file

Crowdr configuration file is bash script. Crowdr require to provide three variables:

The crowdr_config value is multi-line string. Blank lines and lines starting with # are ignored. Every other lines should have following format:

container_name option_name option_value

where:

As an example consider following crowdr configuration:

#!/bin/bash

crowdr_project="example02"
crowdr_name_format="%s-%s"

crowdr_config="
postgresql image postgres:9.4.5
postgresql env POSTGRES_PASSWORD=secret-pass
postgresql volume $(crowdr_fullname postgresql-data):/var/lib/postgresql/data
"

After executing crowdr run the following command will be run:

docker run -td \
           --name   example02-postgresql \
           --env    POSTGRES_PASSWORD=secretpass \
           --volume postgresql-data:/var/lib/postgresql/data \
           postgres:9.4.5

Location and name of configuration file

Crowdr options

Commands

The commands operates only on containers and images specified in configuration.

To enable debug mode set CROWDR_TRACE variable.

CROWDR_TRACE=1 crowdr run |& less

To review planned commands without executing them set CROWDR_DRY variable.

CROWDR_DRY=1 crowdr |& less

Hooks

Every crowdr command can be extended. Lets say you want to pull in some Dockerfiles from remote repositories before running crowdr build.

$ mkdir .crowdr/hooks
$ echo 'echo pulling repos' > .crowdr/hooks/before.build
$ echo 'git clone http://github.com/someuser/docker.redis' >> .crowdr/hooks/before.build
$ echo 'git clone http://github.com/someuser/docker.proxy' >> .crowdr/hooks/before.build
$ chmod 755 .crowdr/hooks/*
$ crowdr build
pulling repos

Crowdr detects both before.* and after.* hooks of each crowdr command.

Crowdr supports also hooks executed only for specified containers. See before.* and after.* in crowdr options.