Skip to content

Instantly share code, notes, and snippets.

@cameron
Created September 4, 2014 06:01
Show Gist options
  • Save cameron/5a7e7ddd5b1ca2a6084c to your computer and use it in GitHub Desktop.
Save cameron/5a7e7ddd5b1ca2a6084c to your computer and use it in GitHub Desktop.
using expect to automate shells and tests in docker containers
#! /usr/bin/expect -f
# ssh into the vagrant coreos machine
spawn ssh coreos
# find a prompt inside the vagrant vm
expect "*core@core*"
# get a shell inside the docker container
send "sudo nsenter --target \$(docker inspect --format '{{.State.Pid}}' \$(docker ps | grep dex_server:latest | awk '{print \$1}')) --mount --uts --ipc --net --pid\r"
# find a prompt inside the docker container"
expect "*root*"
interact
#! /usr/bin/expect
cd [ file dirname $argv0]
# get a shell in the server container
spawn ./shell
# find a prompt inside the docker container
expect "*root*"
# run the tests
send "python /srv/app/legalease/tests/document.py\r"
# find that the tests have finished
expect "*root*"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment