Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 6054dcb

Browse files
committed
Update run.sh formatting
1 parent e1b760f commit 6054dcb

File tree

3 files changed

+54
-39
lines changed

3 files changed

+54
-39
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,23 @@ You can replace the last line with any docker-compose command and argument, whic
7878

7979
### Recommended method
8080

81-
We provide a very convenient script that allows the docker-compose container to run as if it was installed natively:
81+
We provide a very convenient script that allows the docker-compose container to run as if it was installed natively.
82+
83+
First run the following commands to setup the script:
84+
8285
```
86+
export DOCKER_COMPOSE_IMAGE_TAG=ghcr.io/linuxserver/docker-compose:latest
8387
sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
8488
sudo chmod +x /usr/local/bin/docker-compose
8589
```
86-
Running these two commands on your docker host once will let you issue commands such as `docker-compose up -d` and the docker-compose container will do its job behind the scenes.
90+
91+
After running these commands you can issue commands such as `docker-compose up -d` and the docker-compose container will do its job behind the scenes.
92+
93+
The `DOCKER_COMPOSE_IMAGE_TAG` variable needs to be made persistent in order to continue using our image after logging our or rebooting. To do this you will need to edit `/etc/environment` and add or set the following variable:
94+
95+
```
96+
DOCKER_COMPOSE_IMAGE_TAG=ghcr.io/linuxserver/docker-compose:latest
97+
```
8798

8899
### Binaries
89100

@@ -128,6 +139,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
128139

129140
## Versions
130141

142+
* **03.11.20:** - Update run.sh with formatting changes. IMPORTANT!! This now requires a `DOCKER_COMPOSE_IMAGE_TAG` variable to be set in order to use our image! See https://github.com/linuxserver/docker-docker-compose#recommended-method for instructions!
131143
* **04.10.20:** - Update run.sh with changes from upstream.
132144
* **31.08.20:** - Update tox and virtualenv.
133145
* **31.07.20:** - Add support for global env var `DOCKER_COMPOSE_IMAGE_TAG` in the `run.sh` script.

readme-vars.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,23 @@ full_custom_readme: |
8181
8282
### Recommended method
8383
84-
We provide a very convenient script that allows the docker-compose container to run as if it was installed natively:
84+
We provide a very convenient script that allows the docker-compose container to run as if it was installed natively.
85+
86+
First run the following commands to setup the script:
87+
8588
```
89+
export DOCKER_COMPOSE_IMAGE_TAG=ghcr.io/linuxserver/docker-compose:latest
8690
sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
8791
sudo chmod +x /usr/local/bin/docker-compose
8892
```
89-
Running these two commands on your docker host once will let you issue commands such as `docker-compose up -d` and the docker-compose container will do its job behind the scenes.
93+
94+
After running these commands you can issue commands such as `docker-compose up -d` and the docker-compose container will do its job behind the scenes.
95+
96+
The `DOCKER_COMPOSE_IMAGE_TAG` variable needs to be made persistent in order to continue using our image after logging our or rebooting. To do this you will need to edit `/etc/environment` and add or set the following variable:
97+
98+
```
99+
DOCKER_COMPOSE_IMAGE_TAG=ghcr.io/linuxserver/docker-compose:latest
100+
```
90101
91102
### Binaries
92103
@@ -131,6 +142,7 @@ full_custom_readme: |
131142
132143
## Versions
133144
145+
* **03.11.20:** - Update run.sh with formatting changes. IMPORTANT!! This now requires a `DOCKER_COMPOSE_IMAGE_TAG` variable to be set in order to use our image! See https://github.com/linuxserver/docker-docker-compose#recommended-method for instructions!
134146
* **04.10.20:** - Update run.sh with changes from upstream.
135147
* **31.08.20:** - Update tox and virtualenv.
136148
* **31.07.20:** - Add support for global env var `DOCKER_COMPOSE_IMAGE_TAG` in the `run.sh` script.

run.sh

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
#!/bin/sh
22
#
3-
# Forked from https://github.com/docker/compose/blob/master/script/run/run.sh
4-
#
53
# Run docker-compose in a container
64
#
75
# This script will attempt to mirror the host paths by using volumes for the
86
# following paths:
9-
# * $(pwd)
10-
# * $(dirname $COMPOSE_FILE) if it's set
11-
# * $HOME if it's set
7+
# * ${PWD}
8+
# * $(dirname ${COMPOSE_FILE}) if it's set
9+
# * ${HOME} if it's set
1210
#
1311
# You can add additional volumes (or any docker run options) using
14-
# the $COMPOSE_OPTIONS environment variable.
12+
# the ${COMPOSE_OPTIONS} environment variable.
1513
#
16-
# You can set a specific image tag from Docker Hub, such as "1.26.2-ls9", or "alpine"
17-
# using the $DOCKER_COMPOSE_IMAGE_TAG environment variable (defaults to "latest")
14+
# You can set a specific image and tag, such as "docker/compose:1.27.4", or "docker/compose:alpine-1.27.4"
15+
# using the $DOCKER_COMPOSE_IMAGE_TAG environment variable (defaults to "docker/compose:1.27.4")
1816
#
1917

20-
2118
set -e
2219

23-
# set image tag to latest if not globally set
24-
DOCKER_COMPOSE_IMAGE_TAG="${DOCKER_COMPOSE_IMAGE_TAG:-latest}"
25-
IMAGE="ghcr.io/linuxserver/docker-compose:$DOCKER_COMPOSE_IMAGE_TAG"
26-
2720
# Setup options for connecting to docker host
28-
if [ -z "$DOCKER_HOST" ]; then
21+
if [ -z "${DOCKER_HOST}" ]; then
2922
DOCKER_HOST='unix:///var/run/docker.sock'
3023
fi
3124
if [ -S "${DOCKER_HOST#unix://}" ]; then
@@ -34,47 +27,45 @@ else
3427
DOCKER_ADDR="-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH"
3528
fi
3629

37-
3830
# Setup volume mounts for compose config and context
39-
if [ "$(pwd)" != '/' ]; then
40-
VOLUMES="-v $(pwd):$(pwd)"
31+
if [ "${PWD}" != '/' ]; then
32+
VOLUMES="-v ${PWD}:${PWD}"
4133
fi
42-
if [ -n "$COMPOSE_FILE" ]; then
43-
COMPOSE_OPTIONS="$COMPOSE_OPTIONS -e COMPOSE_FILE=$COMPOSE_FILE"
44-
compose_dir="$(dirname "$COMPOSE_FILE")"
34+
if [ -n "${COMPOSE_FILE}" ]; then
35+
COMPOSE_OPTIONS="${COMPOSE_OPTIONS} -e COMPOSE_FILE=${COMPOSE_FILE}"
36+
COMPOSE_DIR="$(dirname "${COMPOSE_FILE}")"
4537
# canonicalize dir, do not use realpath or readlink -f
4638
# since they are not available in some systems (e.g. macOS).
47-
compose_dir="$(cd "$compose_dir" && pwd)"
39+
COMPOSE_DIR="$(cd "${COMPOSE_DIR}" && pwd)"
4840
fi
49-
if [ -n "$COMPOSE_PROJECT_NAME" ]; then
50-
COMPOSE_OPTIONS="-e COMPOSE_PROJECT_NAME $COMPOSE_OPTIONS"
41+
if [ -n "${COMPOSE_PROJECT_NAME}" ]; then
42+
COMPOSE_OPTIONS="-e COMPOSE_PROJECT_NAME ${COMPOSE_OPTIONS}"
5143
fi
5244
# TODO: also check --file argument
53-
if [ -n "$compose_dir" ]; then
54-
VOLUMES="$VOLUMES -v $compose_dir:$compose_dir"
45+
if [ -n "${COMPOSE_DIR}" ]; then
46+
VOLUMES="${VOLUMES} -v ${COMPOSE_DIR}:${COMPOSE_DIR}"
5547
fi
56-
if [ -n "$HOME" ]; then
57-
VOLUMES="$VOLUMES -v $HOME:$HOME -e HOME" # Pass in HOME to share docker.config and allow ~/-relative paths to work.
48+
if [ -n "${HOME}" ]; then
49+
VOLUMES="${VOLUMES} -v ${HOME}:${HOME} -e HOME" # Pass in HOME to share docker.config and allow ~/-relative paths to work.
5850
fi
5951

6052
# Only allocate tty if we detect one
6153
if [ -t 0 ] && [ -t 1 ]; then
62-
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -t"
54+
DOCKER_RUN_OPTIONS="${DOCKER_RUN_OPTIONS} -t"
6355
fi
6456

6557
# Always set -i to support piped and terminal input in run/exec
66-
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i"
67-
58+
DOCKER_RUN_OPTIONS="${DOCKER_RUN_OPTIONS} -i"
6859

6960
# Handle userns security
70-
if docker info --format '{{json .SecurityOptions}}' 2>/dev/null | grep -q 'name=userns'; then
71-
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS --userns=host"
61+
if docker info --format '{{json .SecurityOptions}}' 2> /dev/null | grep -q 'name=userns'; then
62+
DOCKER_RUN_OPTIONS="${DOCKER_RUN_OPTIONS} --userns=host"
7263
fi
7364

7465
# Detect SELinux and add --privileged if necessary
75-
if docker info --format '{{json .SecurityOptions}}' 2>/dev/null | grep -q 'name=selinux'; then
76-
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS --privileged"
66+
if docker info --format '{{json .SecurityOptions}}' 2> /dev/null | grep -q 'name=selinux'; then
67+
DOCKER_RUN_OPTIONS="${DOCKER_RUN_OPTIONS} --privileged"
7768
fi
7869

7970
# shellcheck disable=SC2086
80-
exec docker run --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w "$(pwd)" $IMAGE "$@"
71+
exec docker run --rm ${DOCKER_RUN_OPTIONS} ${DOCKER_ADDR} ${COMPOSE_OPTIONS} ${VOLUMES} -w "${PWD}" "${DOCKER_COMPOSE_IMAGE_TAG:-docker/compose:1.27.4}" "$@"

0 commit comments

Comments
 (0)