Docker utilities to try out recipes and the commands

This commit is contained in:
Bruno Tavares 2014-02-20 12:49:57 -03:00
parent ce2ac5e848
commit 749fbae08c
3 changed files with 47 additions and 0 deletions

View File

@ -33,6 +33,20 @@ Creates a sample project structure
kickstart create [folder name or current folder]
```
#### docker-create
Creates a docker container with a running sshd to test recipes
```bash
kickstart docker-create
```
#### docker-ssh
Access the created docker container over ssh. A simple utility that looks up for the port the docker is bound.
```bash
kickstart docker-ssh
```
### Thanks
This project was inspired on [sunzi](https://github.com/kenn/sunzi)

26
lib/kickstart-docker-create Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash -e
pull_sshd_image() {
docker pull moul/sshd
}
remove_running_sshd() {
runnig_sshd=$(docker ps -q moul/sshd)
[ "$runnig_sshd" ] && docker kill "$runnig_sshd" && docker rm "$runnig_sshd"
true
}
run_sshd() {
id=$(docker run -p 22 -d moul/sshd)
[ -z "$id" ] && echo "Docker container did't start" && return 1
echo "Connect using root:root on " `docker port $id 22`
port=`docker port $id 22 | cut -f 2 -d :`
echo For ssh: ssh -p $port root@localhost
echo For deploy: kickstart deploy \"-p $port root@localhost\" '[roles]'
}
pull_sshd_image
remove_running_sshd
run_sshd

7
lib/kickstart-docker-ssh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash -e
runnig_sshd=$(docker ps -q moul/sshd)
[ -z "$runnig_sshd" ] && echo "Docker container not created. Run \`kickstart docker-create\` to get one" && exit 1
port=`docker port $runnig_sshd 22 | cut -f 2 -d :`
exec ssh -p $port root@localhost