Created
March 6, 2015 22:16
-
-
Save usmanismail/13ae94d8b9e860058bb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage(){ | |
echo "Usage: $0 RANCHER_SERVER CONTAINER_NAME IMAGE COMPUTE_NODE" | |
echo "e.g. $0 my-rancher.com MyContainer ubuntu 1h2" | |
exit 1 | |
} | |
# call usage() function if filename not supplied | |
[[ $# -ne 4 ]] && usage | |
RANCHER_SERVER=$1 | |
CONTAINER_NAME=$2 | |
IMAGE=$3 | |
COMPUTE_NODE=$4 | |
cat <<EOF > /tmp/data | |
{ | |
"startOnCreate": true, | |
"publishAllPorts": false, | |
"privileged": false, | |
"stdinOpen": true, | |
"tty": true, | |
"commandArgs": [], | |
"networkIds": [ | |
"1n2" | |
], | |
"environment": { }, | |
"requestedHostId": "${COMPUTE_NODE}", | |
"dataVolumes": [ | |
"/OUTSIDE_CONTAINER:/INSIDE_CONTAINER" | |
], | |
"dataVolumesFrom": [], | |
"dns": [], | |
"dnsSearch": [], | |
"capAdd": [], | |
"capDrop": [], | |
"lxcConf": {}, | |
"devices": [], | |
"imageUuid": "docker:${IMAGE}", | |
"restartPolicy": { | |
"name": "no" | |
}, | |
"name": "${CONTAINER_NAME}", | |
"ports": [ | |
"8080:8080/tcp" | |
], | |
"instanceLinks": {} | |
} | |
EOF | |
curl -u "${API_KEY}:${API_SECRET}" -X POST \ | |
-H 'Accept: application/json' \ | |
-H 'Content-Type: application/json' \ | |
--data @/tmp/data \ | |
'http://${RANCHER_SERVER}:8080/v1/container' | |
rm -rf /tmp/data | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment