Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/acavalin/dswarm

Easily manage docker stacks, services, images, contexts and repositories
https://github.com/acavalin/dswarm

cli docker docker-compose docker-images docker-machine docker-registry docker-swarm ruby terminal terminal-based

Last synced: 8 days ago
JSON representation

Easily manage docker stacks, services, images, contexts and repositories

Awesome Lists containing this project

README

        

# dswarm
A script to easily manage docker stacks, services, images, contexts and repositories.

## 1. Configuration
This terminal script can operate on your swarms by reading environment variables
for context, stack name, and registry url (thus shortening commands).

You can set each variable in your shell or create a `.dockerswarm` file
in your project's root folder to autoload them at runtime:

~~~yaml
DOCKER_CONTEXT: context_name
DOCKER_STACK: stack_name
DOCKER_REGISTRY: registry.gitlab.com/username/project_name
~~~

## 2. Usage

~~~
USAGE: dswarm [params]
~~~

### 2.1 Actions for managing stacks & services
~~~
[stack-name] [compose.yml]
ls
ps [stack-name] [-u|--usage]
rm [stack-name] [-f|--force]
[-f|--full]
[-p|--pretty]
[-f|--follow]


[command [args]] [-- docker-args]
~~~

Note: The `deploy` action can run the eventual script `dswarm-deploy.hook`
passing the argument `pre`/`post` respectively before and after the deploy process.

### 2.2 Actions for managing images
~~~
# list images
[:tag] [build-folder]

[:tag]

[[:tag]]
clean [-c|--cache]
run [command [args]] [-- docker-args]
~~~

Note: The `build` action can run the eventual script `dswarm-build.hook`
passing the argument `pre`/`post` respectively before and after the build process.
The file must be inside the build folder.

### 2.3 Actions for managing contexts
~~~
ls
add
rm
ssh [remote-command]
~~~

Note: Contexts will be created using by default the SSH adapter but you can always
use `docker context create` to create your own, however keep in mind that the `ssh`
action will not work when using a different adapter.

## 3. Examples

~~~shell
# create a new context
dswarm context add myvps [email protected]

# configure file for dswarm
echo "DOCKER_CONTEXT: myvps" > .dockerswarm
echo "DOCKER_STACK: awesomeapp" >> .dockerswarm
echo "DOCKER_REGISTRY: registry.gitlab.com/jonsmith/awesmeapp.com" >> .dockerswarm

# enters `docker/images/myapp` folder, runs `docker build`
# and tags the image with DOCKER_REGISTRY prefix
dswarm build myapp:v1 docker/images/myapp

# test the image by running it in a ephemeral container
# applying some docker options too (volume and port mappings)
dswarm run myapp bash -ilc screen -- -v /path/to/data:/data -p 3000:3000

# push image to registry
dswarm push myapp

# run some maintenance commands on remote machine
dswarm ssh mkdir -p /app-data
dswarm ssh chown smith:users /app-data

# deploys the `awesomeapp` stack using `awesomeapp.yml` compose file
dswarm deploy

# show process statuses and CPU/MEM usage
dswarm ps --usage

# open a bash shell in the first container running the `myapp` image
# applying some docker options too (change process user)
dswarm exec myapp -- -u smith

# remove the `awesomeapp` stack
dswarm rm
~~~