alpine docker image for running compose and a script to pull and run it with the
correct volumes. Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
5b95c989cd
commit
39cea970b8
4 changed files with 86 additions and 5 deletions
48
script/run
Executable file
48
script/run
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Run docker-compose in a container
|
||||
#
|
||||
# This script will attempt to mirror the host paths by using volumes for the
|
||||
# following paths:
|
||||
# * $(pwd)
|
||||
# * $(dirname $COMPOSE_FILE) if it's set
|
||||
# * $HOME if it's set
|
||||
#
|
||||
# You can add additional volumes (or any docker run options) using
|
||||
# the $COMPOSE_OPTIONS environment variable.
|
||||
#
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
VERSION="1.4.0dev"
|
||||
# TODO: move this to an official repo
|
||||
IMAGE="dnephin/docker-compose:$VERSION"
|
||||
|
||||
|
||||
# Setup options for connecting to docker host
|
||||
if [ -z "$DOCKER_HOST" ]; then
|
||||
DOCKER_HOST="/var/run/docker.sock"
|
||||
fi
|
||||
if [ -S "$DOCKER_HOST" ]; then
|
||||
DOCKER_ADDR="-v $DOCKER_HOST:$DOCKER_HOST -e DOCKER_HOST"
|
||||
else
|
||||
DOCKER_ADDR="-e DOCKER_HOST"
|
||||
fi
|
||||
|
||||
|
||||
# Setup volume mounts for compose config and context
|
||||
VOLUMES="-v $(pwd):$(pwd)"
|
||||
if [ -n "$COMPOSE_FILE" ]; then
|
||||
compose_dir=$(dirname $COMPOSE_FILE)
|
||||
fi
|
||||
# TODO: also check --file argument
|
||||
if [ -n "$compose_dir" ]; then
|
||||
VOLUMES="$VOLUMES -v $compose_dir:$compose_dir"
|
||||
fi
|
||||
if [ -n "$HOME" ]; then
|
||||
VOLUMES="$VOLUMES -v $HOME:$HOME"
|
||||
fi
|
||||
|
||||
|
||||
exec docker run --rm -ti $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w $(pwd) $IMAGE $@
|
||||
Loading…
Add table
Add a link
Reference in a new issue