Skip to content

Instantly share code, notes, and snippets.

@jdeathe
Last active May 18, 2017 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdeathe/e7b09222bb44a2efa6a67b893fe35ac1 to your computer and use it in GitHub Desktop.
Save jdeathe/e7b09222bb44a2efa6a67b893fe35ac1 to your computer and use it in GitHub Desktop.
Alias for docker-compose (version 1.13.0) installed as a docker container

How to Install docker-compose as a Docker Container

It might be desirable to to install docker-compose as a container. The official way is to use wrapper script. Here is an alternative approach using an alias.

Using the Default docker Binary

# alias docker-compose='touch ${PWD}/.env; \
  docker run \
  --privileged \
  --rm \
  --env-file ${PWD}/.env \
  --volume ${PWD}:/tmp/$(basename ${PWD}) \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --workdir /tmp/$(basename ${PWD}) \
  docker/compose:1.13.0'

Using the docker-latest Binary

On CentOS-7 or Centos Atomic Hosts the docker-latest binary can be use to run Docker 1.13. If you have this configured and the alias is for a non-root user use the following example to call docker-latest with sudo.

NOTE: Populate a .env file with any necessary environment variables.

$ alias docker-compose='touch ${PWD}/.env; \
  sudo /usr/bin/docker-latest run \
  --privileged \
  --rm \
  --env-file ${PWD}/.env \
  --volume ${PWD}:/tmp/$(basename ${PWD}) \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --workdir /tmp/$(basename ${PWD}) \
  docker/compose:1.13.0'

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment