Skip to content

Instantly share code, notes, and snippets.

@sweepies
Created March 27, 2019 15:16
Show Gist options
  • Save sweepies/eb2d12d066b55e98f2768040ad4505f4 to your computer and use it in GitHub Desktop.
Save sweepies/eb2d12d066b55e98f2768040ad4505f4 to your computer and use it in GitHub Desktop.
Run docker-compose in docker
#!/bin/sh
# Includes release candidate versions
if [ -t 0 ]; then OPTS='-it'; fi
latest=$(curl -s https://registry.hub.docker.com/v2/repositories/docker/compose/tags/ | jq -r '.results[0].name')
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd):$(pwd)" -w "$(pwd)" \
$OPTS docker/compose:"$latest" ${1+"$@"}
#!/bin/sh
# Does not include release candidates, but fetches from GitHub instead of Docker Hub
# (so it's possible the tag won't exist on Docker Hub)
if [ -t 0 ]; then OPTS='-it'; fi
latest=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.tag_name')
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd):$(pwd)" -w "$(pwd)" \
$OPTS docker/compose:"$latest" ${1+"$@"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment