Docker Compose API provides an easy way to parse docker compose files and lift the whole environment.
Install the gem in whole environment
gem install docker-compose-api
... or using Bundler
# Add the line below on your Gemfile...
gem 'docker-compose-api', git: 'https://github.com/mauricioklein/docker-compose-api'
# ... and run bundle install
bundle install
require 'docker-compose'
# Docker compose is simply a layer running over Docker client (https://github.com/swipely/docker-api).
# So, all Docker specific configurations, such URL, authentication, SSL, etc, must be made directly on
# Docker client.
#
# Docker compose provides an easy way to access this client:
DockerCompose.docker_client
# Gem version
DockerCompose.version
# Loading a compose file
compose = DockerCompose.load('[path to docker compose file]')
# Accessing containers
compose.containers # access all containers
compose.containers['[container name]'] # access a specific container
# Starting containers (and their dependencies)
compose.start # start all containers
compose.start(['container1', 'container2', ...]) # start a list of specific containers
# Stopping containers
# (ps: container dependencies will keep running)
compose.stop # stop all containers
compose.stop(['container1', 'container2', ...]) # stop a list of specific containers
# Killing containers
# (ps: container dependencies will keep running)
compose.kill # kill all containers
compose.kill(['container1', 'container2', ...]) # kill a list of specific containers
# Deleting containers
# (ps: container dependencies will keep running)
compose.delete # delete all containers
compose.delete(['container1', 'container2', ...]) # delete a list of specific containers
# Checking if a container is running or not
a_container = compose.containers['a_container']
a_container.running?
# Accessing container informations
a_container.stats
- Fork it ( https://github.com/mauricioklein/docker-compose-api/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