
image=${1:-"debian:jessie"}
docker pull "$image"
ID=$(docker run -d -ti $image)

[[ -z "$ID" ]] && echo "container couldn't be retrieved" >&2 && exit 1

docker exec -ti $ID apt-get update
docker exec -ti $ID apt-get install -y ssl-cert dialog
docker exec -ti $ID apt-get install -y nginx-common nginx-light
docker exec -ti $ID cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
docker exec -ti $ID sed -i -e 's/# listen/listen/' -e 's/# include/include/' /etc/nginx/sites-available/default
docker exec -ti $ID sed -i -e 's/listen \[::\]:443 ssl default_server;/&\n\tssl_protocols           SSLv3 TLSv1 TLSv1\.1 TLSv1\.2;\n/' /etc/nginx/sites-available/default

docker exec -ti $ID nginx -V
docker exec -ti $ID service nginx start
docker exec -ti $ID service nginx status
# P Q

docker inspect $ID | jq -r '.[].NetworkSettings.IPAddress'

exit 0



