Skip to content

Instantly share code, notes, and snippets.

@bobmaerten
Created May 27, 2015 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobmaerten/34aef05fffe605673466 to your computer and use it in GitHub Desktop.
Save bobmaerten/34aef05fffe605673466 to your computer and use it in GitHub Desktop.
Run PHP CLI script with Docker
#!/usr/bin/env bash
die() { echo "$@" 1>&2 ; exit 1; }
[ "$#" -ne 1 ] && die "usage: $0 <php script>"
head -n 1 $1 | grep -q "^<?php" || die "error: only runs php scripts"
eval "$(docker-machine env dev)"
docker run -it --rm --name my-running-script -v $(pwd):/usr/src/myapp -w /usr/src/myapp php:5.6-cli php $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment