Barnacle
All I want from Docker is convenience and the ability to run isolate services. I don't want to push to registries, tag images, manage containers, etc. I created this simple gem to hide these complexities.
There are only four ways to run barnacle, and you can probably guess what they do.
up
down
status
enter
Requires
docker version >= 1.5.0
some reasonable version of ruby
Install
This is a ruby script packaged in a ruby gem.
shell> gem install barnacle
or Gemfile:
gem 'barnacle'
Setup
Place your Dockerfile and an optional file named config.yml in your services root directory. barnacle will look for these files in a directory named barnacle. The Dockerfile will probably contain an ADD statement to include some or all of the directory tree - but that's up to you. Your Dockerfile will definitely need a CMD because there's no way to pass arguments to barnacle - a design decision for simplicy, the objective of barnacle.
my_service/
├── app
├── barnacle
│ ├── config.yml
│ └── Dockerfile
├── bin
└── lib
Execution and Defaults
Defaults:
- detach = true
- [name] = current directory name
- [hostname] = current directory name
If you want to override any defaults put them in the barnacle/config.yml file described in the next section.
barnacle up (runs)
docker build -f barnacle/Dockerfile -t [name]
docker rm -f [name]
docker run --detach=true --name=[name] --hostname=[hostname] [config.yml switches] [name]
barnacle down (runs)
docker stop NAME
barnacle status (just highlights line with [name] in the name column)
docker ps -a
docker enter (executes)
docker exec -ti NAME bash
config.yml
This file is made up only of command line switches passed to docker commands.
Example config.yml:
docker:
privileged: true
v:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /var/log/relay:/var/log
The above config.yml results in these additional command line switches for $>docker up
--priviledged=true -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /var/log/relay:/var/log
Workflow
Just a suggestion for production deployment.
Get changes up to production server (git push/pull, rsync, floppy, whatever)
Log into remote host... cd to service's directory
barnacle up
If you are more sophisticated you might combine all these steps in a single command - like a rake task utilizing ssh -c for the remote commands, or even something like Ansible.
No image repository is needed except for the base image on the first run. If you keep your images up on the production server, and are smart about your Dockerfile, this should be a very quick deployment.
Note: if you are deploying rails don't forget to put 'bundle install', compile assets, and tell the web server of the changes in your Dockerfile. (research into caching as much 'bundle install' as possible)
Contributing
- Fork it ( https://github.com/[my-github-username]/barnacle/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request