Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
.tox
build
coverage-html
dist
docs/_site
venv
.tox
15 changes: 15 additions & 0 deletions Dockerfile.run
Original file line number Diff line number Diff line change
@@ -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"]
26 changes: 22 additions & 4 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions script/run
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You write really helpful doc strings for your bash scripts 👍

# 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"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open an issue to get this image published to a better repo, and add notes to the release process doc about updating it on release.



# 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)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use "$PWD" (which will be set by the shell) and avoid the subshells here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would probably work as well. There are times when $PWD isn't set (if you fork/exec without a shell for example).

Does this cause a problem?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No serious problem, just calling out the unnecessary subshell.

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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does everything work fine if $(pwd) is a subdir of $HOME and we get overlapping volume mounts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, that doesn't seem to be a problem from what I can tell

fi


exec docker run --rm -ti $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w $(pwd) $IMAGE $@