Module to import docker-compose via saltstack
New in version 2016.3.0.
maintainer: | Jean Praloran <jeanpralo@gmail.com> |
---|---|
maturity: | new |
depends: | docker-compose>=1.5 |
platform: | all |
This module allows one to deal with docker-compose file in a directory.
This is a first version only, the following commands are missing at the moment but will be built later on if the community is interested in this module:
This execution module requires at least version 1.4.0 of both docker-compose and Docker. docker-compose can easily be installed using pip.install
:
salt myminion pip.install docker-compose>=1.5.0
In order to use the module if you have no docker-compose file on the server you can issue the command create, it takes two arguments the path where the docker-compose.yml will be stored and the content of this latter:
# salt-call -l debug dockercompose.create /tmp/toto ' database: image: mongo:3.0 command: mongod --smallfiles --quiet --logpath=/dev/null '
Then you can execute a list of method defined at the bottom with at least one argument (the path where the docker-compose.yml will be read) and an optional python list which corresponds to the services names:
# salt-call -l debug dockercompose.up /tmp/toto # salt-call -l debug dockercompose.restart /tmp/toto '[database]' # salt-call -l debug dockercompose.stop /tmp/toto # salt-call -l debug dockercompose.rm /tmp/toto
Build image for containers in the docker-compose file, service_names is a python list, if omitted build images for all containers. Please note that at the moment the module does not allow you to upload your Dockerfile, nor any other file you could need with your docker-compose.yml, you will have to make sure the files you need are actually in the directory specified in the build keyword
CLI Example:
salt myminion dockercompose.build /path/where/docker-compose/stored salt myminion dockercompose.build /path/where/docker-compose/stored '[janus]'
Create and validate a docker-compose file into a directory
CLI Example:
salt myminion dockercompose.create /path/where/docker-compose/stored content
Get the content of the docker-compose file into a directory
CLI Example:
salt myminion dockercompose.get /path/where/docker-compose/stored
Kill containers in the docker-compose file, service_names is a python list, if omitted kill all containers
CLI Example:
salt myminion dockercompose.kill /path/where/docker-compose/stored salt myminion dockercompose.kill /path/where/docker-compose/stored '[janus]'
Pause running containers in the docker-compose file, service_names is a python list, if omitted pause all containers
CLI Example:
salt myminion dockercompose.pause /path/where/docker-compose/stored salt myminion dockercompose.pause /path/where/docker-compose/stored '[janus]'
List all running containers and report some information about them
CLI Example:
salt myminion dockercompose.ps /path/where/docker-compose/stored
Pull image for containers in the docker-compose file, service_names is a python list, if omitted pull all images
CLI Example:
salt myminion dockercompose.pull /path/where/docker-compose/stored salt myminion dockercompose.pull /path/where/docker-compose/stored '[janus]'
Restart container(s) in the docker-compose file, service_names is a python list, if omitted restart all containers
CLI Example:
salt myminion dockercompose.restart /path/where/docker-compose/stored salt myminion dockercompose.restart /path/where/docker-compose/stored '[janus]'
Remove stopped containers in the docker-compose file, service_names is a python list, if omitted remove all stopped containers
CLI Example:
salt myminion dockercompose.rm /path/where/docker-compose/stored salt myminion dockercompose.rm /path/where/docker-compose/stored '[janus]'
Create the definition of a docker-compose service This fails when the service already exists This does not pull or up the service This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
CLI Example:
salt myminion dockercompose.service_create /path/where/docker-compose/stored service_name definition
Remove the definition of a docker-compose service This does not rm the container This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
CLI Example:
salt myminion dockercompose.service_remove /path/where/docker-compose/stored service_name
Change the tag of a docker-compose service This does not pull or up the service This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
CLI Example:
salt myminion dockercompose.service_create /path/where/docker-compose/stored service_name tag
Create or update the definition of a docker-compose service This does not pull or up the service This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
CLI Example:
salt myminion dockercompose.service_upsert /path/where/docker-compose/stored service_name definition
Start containers in the docker-compose file, service_names is a python list, if omitted start all containers
CLI Example:
salt myminion dockercompose.start /path/where/docker-compose/stored salt myminion dockercompose.start /path/where/docker-compose/stored '[janus]'
Stop running containers in the docker-compose file, service_names is a python list, if omitted stop all containers
CLI Example:
salt myminion dockercompose.stop /path/where/docker-compose/stored salt myminion dockercompose.stop /path/where/docker-compose/stored '[janus]'
Un-Pause containers in the docker-compose file, service_names is a python list, if omitted unpause all containers
CLI Example:
salt myminion dockercompose.pause /path/where/docker-compose/stored salt myminion dockercompose.pause /path/where/docker-compose/stored '[janus]'
Create and start containers defined in the docker-compose.yml file located in path, service_names is a python list, if omitted create and start all containers
CLI Example:
salt myminion dockercompose.up /path/where/docker-compose/stored salt myminion dockercompose.up /path/where/docker-compose/stored '[janus]'
© 2019 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.dockercompose.html