Add support for using different docker images

The part of trying out scripts involve creating a docker container with
ssh and running some projects and functions on it.

This change allows to define the docker image name to be used with the
docker-* functions.
This commit is contained in:
Bruno Tavares 2014-03-02 20:09:25 -03:00
parent 56bf615b34
commit c9633bb7b9
3 changed files with 22 additions and 6 deletions

View File

@ -51,14 +51,14 @@ kickstart create [folder name or current folder]
Creates a docker container with a running sshd to test recipes
```bash
kickstart docker-create
kickstart docker-create [image-name]
```
#### 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
kickstart docker-ssh [image-name]
```
@ -162,5 +162,15 @@ Prepend DEBUG=1 to the command and you will see massive ammount of commands on y
DEBUG=1 kickstart local nodejs
```
### Choosing the docker image to use
You can choose an specific image to use on the docker-* commands.
On order, it looks up for an image as an argument, on the `KICKSTART_DOCKER_IMAGE` env variable or defaults to moul/sshd.
You can use any image that is on the index, you probably want it to have an sshd running by default.
Docker images tested:
* [moul/sshd](https://index.docker.io/u/moul/sshd/)
* [bltavares/centos-ssh](https://index.docker.io/u/bltavares/centos-ssh/)
### Thanks
This project was inspired on [sunzi](https://github.com/kenn/sunzi)

View File

@ -1,17 +1,20 @@
#!/bin/bash -e
image_name=${1:-$KICKSTART_DOCKER_IMAGE}
image_name=${image_name:-moul/sshd}
pull_sshd_image() {
docker pull moul/sshd
docker pull $image_name
}
remove_running_sshd() {
runnig_sshd=$(docker ps -q moul/sshd)
runnig_sshd=$(docker ps -q $image_name)
[ "$runnig_sshd" ] && docker kill "$runnig_sshd" && docker rm "$runnig_sshd"
true
}
run_sshd() {
id=$(docker run -p 22 -d moul/sshd)
id=$(docker run -p 22 -d $image_name)
[ -z "$id" ] && echo "Docker container did't start" && return 1

View File

@ -1,6 +1,9 @@
#!/bin/bash -e
runnig_sshd=$(docker ps -q moul/sshd)
image_name=${1:-$KICKSTART_DOCKER_IMAGE}
image_name=${image_name:-moul/sshd}
runnig_sshd=$(docker ps -q $image_name)
[ -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 :`