mirror of https://github.com/docker/compose.git
Merge pull request #1806 from dnephin/run_script
Docker image and bash script for running compose in a container
This commit is contained in:
commit
19271898de
|
@ -4,6 +4,6 @@
|
||||||
.tox
|
.tox
|
||||||
build
|
build
|
||||||
coverage-html
|
coverage-html
|
||||||
dist
|
|
||||||
docs/_site
|
docs/_site
|
||||||
venv
|
venv
|
||||||
|
.tox
|
||||||
|
|
|
@ -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"]
|
|
@ -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
|
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
|
$ 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.
|
`bash` and `zsh` shell.
|
||||||
|
|
||||||
6. Test the installation.
|
7. Test the installation.
|
||||||
|
|
||||||
$ docker-compose --version
|
$ docker-compose --version
|
||||||
docker-compose version: 1.4.2
|
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
|
## Upgrading
|
||||||
|
|
||||||
If you're upgrading from Compose 1.2 or earlier, you'll need to remove or migrate
|
If you're upgrading from Compose 1.2 or earlier, you'll need to remove or migrate
|
||||||
|
|
|
@ -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…
Reference in New Issue