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

Commit 44775d9

Browse files
authored
Merge pull request #20 from linuxserver/run.sh
Update run.sh formatting
2 parents 21af44f + f014d17 commit 44775d9

File tree

3 files changed

+43
-35
lines changed

3 files changed

+43
-35
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 out 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ full_custom_readme: |
8282
### Recommended method
8383
8484
We provide a very convenient script that allows the docker-compose container to run as if it was installed natively:
85+
8586
```
8687
sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
8788
sudo chmod +x /usr/local/bin/docker-compose
8889
```
90+
8991
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.
9092
9193
### Binaries
@@ -131,6 +133,7 @@ full_custom_readme: |
131133
132134
## Versions
133135
136+
* **17.12.20:** - Update run.sh with formatting changes.
134137
* **04.10.20:** - Update run.sh with changes from upstream.
135138
* **31.08.20:** - Update tox and virtualenv.
136139
* **31.07.20:** - Add support for global env var `DOCKER_COMPOSE_IMAGE_TAG` in the `run.sh` script.

run.sh

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,21 @@
66
#
77
# This script will attempt to mirror the host paths by using volumes for the
88
# following paths:
9-
# * $(pwd)
10-
# * $(dirname $COMPOSE_FILE) if it's set
11-
# * $HOME if it's set
9+
# * ${PWD}
10+
# * $(dirname ${COMPOSE_FILE}) if it's set
11+
# * ${HOME} if it's set
1212
#
1313
# You can add additional volumes (or any docker run options) using
14-
# the $COMPOSE_OPTIONS environment variable.
14+
# the ${COMPOSE_OPTIONS} environment variable.
1515
#
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")
16+
# You can set a specific image and tag, such as "ghcr.io/linuxserver/docker-compose:version-1.27.4", or "ghcr.io/linuxserver/docker-compose:alpine"
17+
# using the $DOCKER_COMPOSE_IMAGE_TAG environment variable (defaults to "ghcr.io/linuxserver/docker-compose:latest")
1818
#
1919

20-
2120
set -e
2221

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-
2722
# Setup options for connecting to docker host
28-
if [ -z "$DOCKER_HOST" ]; then
23+
if [ -z "${DOCKER_HOST}" ]; then
2924
DOCKER_HOST='unix:///var/run/docker.sock'
3025
fi
3126
if [ -S "${DOCKER_HOST#unix://}" ]; then
@@ -34,47 +29,45 @@ else
3429
DOCKER_ADDR="-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH"
3530
fi
3631

37-
3832
# Setup volume mounts for compose config and context
39-
if [ "$(pwd)" != '/' ]; then
40-
VOLUMES="-v $(pwd):$(pwd)"
33+
if [ "${PWD}" != '/' ]; then
34+
VOLUMES="-v ${PWD}:${PWD}"
4135
fi
42-
if [ -n "$COMPOSE_FILE" ]; then
43-
COMPOSE_OPTIONS="$COMPOSE_OPTIONS -e COMPOSE_FILE=$COMPOSE_FILE"
44-
compose_dir="$(dirname "$COMPOSE_FILE")"
36+
if [ -n "${COMPOSE_FILE}" ]; then
37+
COMPOSE_OPTIONS="${COMPOSE_OPTIONS} -e COMPOSE_FILE=${COMPOSE_FILE}"
38+
COMPOSE_DIR="$(dirname "${COMPOSE_FILE}")"
4539
# canonicalize dir, do not use realpath or readlink -f
4640
# since they are not available in some systems (e.g. macOS).
47-
compose_dir="$(cd "$compose_dir" && pwd)"
41+
COMPOSE_DIR="$(cd "${COMPOSE_DIR}" && pwd)"
4842
fi
49-
if [ -n "$COMPOSE_PROJECT_NAME" ]; then
50-
COMPOSE_OPTIONS="-e COMPOSE_PROJECT_NAME $COMPOSE_OPTIONS"
43+
if [ -n "${COMPOSE_PROJECT_NAME}" ]; then
44+
COMPOSE_OPTIONS="-e COMPOSE_PROJECT_NAME ${COMPOSE_OPTIONS}"
5145
fi
5246
# TODO: also check --file argument
53-
if [ -n "$compose_dir" ]; then
54-
VOLUMES="$VOLUMES -v $compose_dir:$compose_dir"
47+
if [ -n "${COMPOSE_DIR}" ]; then
48+
VOLUMES="${VOLUMES} -v ${COMPOSE_DIR}:${COMPOSE_DIR}"
5549
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.
50+
if [ -n "${HOME}" ]; then
51+
VOLUMES="${VOLUMES} -v ${HOME}:${HOME} -e HOME" # Pass in HOME to share docker.config and allow ~/-relative paths to work.
5852
fi
5953

6054
# Only allocate tty if we detect one
6155
if [ -t 0 ] && [ -t 1 ]; then
62-
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -t"
56+
DOCKER_RUN_OPTIONS="${DOCKER_RUN_OPTIONS} -t"
6357
fi
6458

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

6962
# 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"
63+
if docker info --format '{{json .SecurityOptions}}' 2> /dev/null | grep -q 'name=userns'; then
64+
DOCKER_RUN_OPTIONS="${DOCKER_RUN_OPTIONS} --userns=host"
7265
fi
7366

7467
# 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"
68+
if docker info --format '{{json .SecurityOptions}}' 2> /dev/null | grep -q 'name=selinux'; then
69+
DOCKER_RUN_OPTIONS="${DOCKER_RUN_OPTIONS} --privileged"
7770
fi
7871

7972
# shellcheck disable=SC2086
80-
exec docker run --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w "$(pwd)" $IMAGE "$@"
73+
exec docker run --rm ${DOCKER_RUN_OPTIONS} ${DOCKER_ADDR} ${COMPOSE_OPTIONS} ${VOLUMES} -w "${PWD}" "${DOCKER_COMPOSE_IMAGE_TAG:-ghcr.io/linuxserver/docker-compose:latest}" "$@"

0 commit comments

Comments
 (0)