diff --git a/.dockerignore b/.dockerignore index 5a4da301b..055ae7ed1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,6 @@ .tox build coverage-html -dist docs/_site venv +.tox diff --git a/Dockerfile.run b/Dockerfile.run new file mode 100644 index 000000000..3c12fa182 --- /dev/null +++ b/Dockerfile.run @@ -0,0 +1,15 @@ + +FROM alpine:edge +RUN apk -U add \ + python \ + py-pip + +COPY requirements.txt /code/requirements.txt +RUN pip install -r /code/requirements.txt + +ENV VERSION 1.4.0dev + +COPY dist/docker-compose-$VERSION.tar.gz /code/docker-compose/ +RUN pip install /code/docker-compose/docker-compose-$VERSION/ + +ENTRYPOINT ["/usr/bin/docker-compose"] diff --git a/docs/install.md b/docs/install.md index bc1f8f78c..fd7b3cabf 100644 --- a/docs/install.md +++ b/docs/install.md @@ -40,20 +40,38 @@ To install Compose, do the following: curl -L https://github.com/docker/compose/releases/download/VERSION_NUM/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose - If you have problems installing with `curl`, you can use `pip` instead: `pip install -U docker-compose` + If you have problems installing with `curl`, see + [Alternative Install Options](#alternative-install-options). -4. Apply executable permissions to the binary: +5. Apply executable permissions to the binary: $ chmod +x /usr/local/bin/docker-compose -5. Optionally, install [command completion](completion.md) for the +6. Optionally, install [command completion](completion.md) for the `bash` and `zsh` shell. -6. Test the installation. +7. Test the installation. $ docker-compose --version docker-compose version: 1.4.2 + +## Alternative install options + +### Install using pip + + $ sudo pip install -U docker-compose + + +### Install as a container + +Compose can also be run inside a container, from a small bash script wrapper. +To install compose as a container run: + + $ curl -L https://github.com/docker/compose/releases/download/1.5.0/compose-run > /usr/local/bin/docker-compose + $ chmod +x /usr/local/bin/docker-compose + + ## Upgrading If you're upgrading from Compose 1.2 or earlier, you'll need to remove or migrate diff --git a/script/run b/script/run new file mode 100755 index 000000000..64718efdc --- /dev/null +++ b/script/run @@ -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 $@